Bug 46176 - Field System.Net.HttpWebRequest:ResendContentFactory is inaccessible from method System.Net.Http.HttpClientHandler
Summary: Field System.Net.HttpWebRequest:ResendContentFactory is inaccessible from met...
Status: RESOLVED DUPLICATE of bug 41133
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-10-31 03:05 UTC by joeperkins
Modified: 2017-01-10 17:22 UTC (History)
4 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description joeperkins 2016-10-31 03:05:20 UTC
Once an application has stared and has received this error, only stopping the application and restarting will allow HttpWebRequests to function again.


System.FieldAccessException: Field `System.Net.HttpWebRequest:ResendContentFactory' is inaccessible from method `System.Net.Http.HttpClientHandler/<SendAsync>c__async0:MoveNext ()'
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00031] in <368820a9888f43ddb85d18e87189adbf>:0 
  at System.Net.Http.HttpClientHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00024] in <1f815edaaf4f498fac92ea3424f688b8>:0 
  at System.Net.Http.HttpMessageInvoker.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00000] in <1f815edaaf4f498fac92ea3424f688b8>:0 
  at System.Net.Http.HttpClient.<SendAsync>__BaseCallProxy0 (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00000] in <1f815edaaf4f498fac92ea3424f688b8>:0 
  at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () [0x00089] in <1f815edaaf4f498fac92ea3424f688b8>:0
Comment 1 Marek Safar 2016-10-31 14:34:25 UTC

*** This bug has been marked as a duplicate of bug 41133 ***
Comment 2 joeperkins 2016-12-08 22:37:25 UTC
Removing the HttpClient (Managed HttpClientHandler) and using HttpWebRequest, HttpWebResponse instead fixed all the following issues.

Note: AndroidClientHander was not tested.

1. Threading race conditions, source of the many types of System.MethodAccessException
2. DNS issues
3. unexpended connection loss or inability to connect to any endpoint after process has started.
4. Slow and hanging downloads

async HttpWebRequest, HttpWebResponse  example:

var request = (HttpWebRequest) WebRequest.Create(uri);  

...

using (WebResponse response = await request.GetResponseAsync())
{
    using (var stream = response.GetResponseStream())
    {
        using (Stream fileStream = new FileStream(filePath, FileMode.Create))
        {
...
Comment 3 ikbenben.rooney 2017-01-10 09:47:13 UTC
Hi Marek Safar. I'm curious why this was marked as a duplicate of bug 41133? The stack traces are different. Seems like it may be related but not sure they are duplicates. Just curious for the reasoning
Comment 4 Marek Safar 2017-01-10 17:22:26 UTC
The stacktrace does not matter. It's race issue in Mono runtime in AOT mode.

Note You need to log in before you can comment on or make changes to this bug.