Bug 18036 - Microsoft.Net.Http PCL Attempting to JIT compile method calling a simple http webservice from PCL
Summary: Microsoft.Net.Http PCL Attempting to JIT compile method calling a simple http...
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.0.7
Hardware: PC Windows
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-02-26 18:26 UTC by softlion
Modified: 2014-09-22 10:40 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 Developer Community or GitHub 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 softlion 2014-02-26 18:26:23 UTC
Exactly like https://bugzilla.xamarin.com/show_bug.cgi?id=14656 which should be resolved.
The problem only appears on ios device, not in Android or in the ios simulator.

Typing --gsharedvt=true in "additional mtouch arguments" did not solved the problem.
Type sharing was already enabled.

Same code was working ok end of december.
Using http://, not https://.


Feb 27 00:09:59 Benjamin AcTouch[682] <Warning>: System.AggregateException: One
or more errors occured ---> System.ExecutionEngineException: Attempting to JIT
compile method '(wrapper delegate-invoke)
(System.Net.HttpWebRequest,bool)' while running with --aot-only. See
http://docs.xamarin.com/ios/about/limitations for more information.

      at System.Lightup.TryCall[HttpWebRequest,Boolean] (System.Delegate&
storage, System.Net.HttpWebRequest instance, System.String methodName, Boolean
parameter) [0x00000] in <filename unknown>:0 
      at System.Lightup.TrySet[HttpWebRequest,Boolean] (System.Delegate&
storage, System.Net.HttpWebRequest instance, System.String propertyName,
Boolean value) [0x00000] in <filename unknown>:0 
      at System.Net.HttpWebRequestLightup.TrySetAllowReadStreamBuffering
(System.Net.HttpWebRequest instance, Boolean value) [0x00000] in <filename
      at System.Net.Http.HttpWebRequest..ctor (System.Uri uri) [0x00000] in
<filename unknown>:0 
      at System.Net.Http.HttpClientHandler.CreateAndPrepareWebRequest
(System.Net.Http.HttpRequestMessage request) [0x00000] in <filename unknown>:0 
      at System.Net.Http.HttpClientHandler.SendAsync
(System.Net.Http.HttpRequestMessage request, CancellationToken
cancellationToken) [0x00000] in <filename unknown>:0 
    --- End of stack trace from previous location where exception was thrown
      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000b] in
() [0x00000] in <filename unknown>:0 
      at Ac.Shared.Tools.Rest+<Request>d__d.MoveNext () [0x002c2] in
      --- End of inner exception stack trace ---
Comment 1 Rolf Bjarne Kvinge [MSFT] 2014-02-27 10:01:46 UTC
Can you please attach a test project we can use to reproduce this?
Comment 2 softlion 2014-03-10 04:15:00 UTC
Test project attached.
I have this bug since mid january, but didn't took time to create a repro. Here
it is.

Comment 3 softlion 2014-03-10 04:15:33 UTC
Comment 4 softlion 2014-03-10 06:54:34 UTC
Another demo.

This one does work on the simulator, but fails on the device with exception "InvalidOperationEception" in internal method SetContentLength.


I also created another one which removes all async/await stuf and runs synchronously.
It still work on simulator, not on device.
Comment 5 softlion 2014-03-10 06:57:05 UTC
I replaced HttpClient with WebClient and it works. But WebClient has not enough features for my needs. And HttpClient was working ok in december !!
Comment 6 Rolf Bjarne Kvinge [MSFT] 2014-03-11 06:01:32 UTC
The test case from comment #4 is working in our latest build, so this will be fixed when 7.2.1 is released.

Still looking at the test case from comment #2.
Comment 7 Shruti 2014-03-11 08:35:54 UTC
I have checked this issue with following steps.

About application attached in section Comment #2.
1.  Launched application using simulator.
2.  It is working fine on simulator.
3.  Now I launched same application using device. It did not deploy and raised exception.

Refer link for exception : https://gist.github.com/Shruti360/04bf769bcf9e60c268ea

About application attached in section Comment #4.
1.  Launched application using simulator.
2.  It is working fine on simulator.
3.  Now I launched same application using device. It deployed and raised exception when clicked on 'Call Http request (directly)'. 
Exception : System.InvalidOperationException: Operation is not valid due to the current state of the object at
System.Lightup.TryCall[HttpWebRequest,int32] (System.Delegate&
storage, System.Net.HttpWebRequest instance, System.String methodName, int32
parameter) [0x00000] in <filename unknown>:0 ................................

Supplement information for device log :

Environment Info:
Xamrin.iOS for VS : 1.10.39
Comment 8 Rolf Bjarne Kvinge [MSFT] 2014-09-22 10:40:10 UTC
This has been fixed at some point, I can't reproduce any issues anymore with the test case from comment #2.