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# ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2016-10-31 03:05 UTC by joeperkins
Modified: 2017-01-10 17:22 UTC (History)
4 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

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.