Bug 14656 - Connecting to SSL server from Apple device results in System.ExecutionEngineException
Summary: Connecting to SSL server from Apple device results in System.ExecutionEngineE...
Status: RESOLVED DUPLICATE of bug 14696
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.4.4
Hardware: PC Windows
: Highest blocker
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-09-11 14:02 UTC by Jon Goldberger [MSFT]
Modified: 2014-02-26 20:36 UTC (History)
10 users (show)

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

test Project (68.63 KB, application/x-7z-compressed)
2013-09-11 14:02 UTC, Jon Goldberger [MSFT]
iOS Build Options (37.53 KB, image/png)
2013-09-17 08:36 UTC, jannic.benitz

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 Jon Goldberger [MSFT] 2013-09-11 14:02:54 UTC
Created attachment 4841 [details]
test Project

the following line of code results in a System.ExecutionEngineException:
using(HttpWebResponse response = (HttpWebResponse) request.GetResponse())
This happens while trying to connect to SSL Server with an Apple Device.
The following Exception occurred the first time, when Xamarin.iOS was updated to the latest version (to 6.4.4).
{System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure --->
System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-begin-invoke)
System.Func`4<byte[], int, int,
int>:begin_invoke_IAsyncResult__this___T1_T2_T3_AsyncCallback_object (byte[],int,int,System.AsyncCallback,object)' while running with --aot-
only. See http://docs.xamarin.com/ios/about/limitations for more information.\n\n at System.IO.Stream.BeginRead (System.Byte[] buffer, Int32
offset, Int32 count, System.AsyncCallback callback, System.Object state) [0x00072] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/Stream.cs:191 \n at Mono.Security.Protocol.Tls.RecordProtocol.BeginReceiveRecord
(System.IO.Stream record, System.AsyncCallback callback, System.Object state) [0x00039] in
/Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:326 \n at
Mono.Security.Protocol.Tls.RecordProtocol.ReceiveRecord (System.IO.Stream record) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:441 \n at
Mono.Security.Protocol.Tls.SslStreamBase.InternalReadCallback (IAsyncResult result) [0x00091] in
/Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs:682 \n --- End of inner exception stack
trace ---\n at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00065] in
/Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:951 \n at System.Net.HttpWebRequest.GetResponse () [0x0000e]
in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:957 \n at RxLibSharp.Service.Json.GetResponse
... }

Please find attached a simple Application to reproduce our problem.
Comment 2 Jon Goldberger [MSFT] 2013-09-12 12:09:20 UTC
Version info:

the Visual Studio version information:

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework
Version 4.5.50709 SP1Rel

Installed Version: Professional

Microsoft Office Developer Tools 01018-587-3106972-70808
Microsoft Office Developer Tools

Microsoft Visual Basic 2010 01018-587-3106972-70808
Microsoft Visual Basic 2010

Microsoft Visual C# 2010 01018-587-3106972-70808
Microsoft Visual C# 2010

Microsoft Visual C++ 2010 01018-587-3106972-70808
Microsoft Visual C++ 2010

Microsoft Visual F# 2010 01018-587-3106972-70808
Microsoft Visual F# 2010

Microsoft Visual Studio 2010 Team Explorer 01018-587-3106972-70808
Microsoft Visual Studio 2010 Team Explorer

Microsoft Visual Web Developer 2010 01018-587-3106972-70808
Microsoft Visual Web Developer 2010

Crystal Reports Templates for Microsoft Visual Studio 2010
Crystal Reports Templates for Microsoft Visual Studio 2010

JetBrains ReSharper 7.1.3 C# Edition build 7.1.3000.2254 on 2013-04-10T15:48:18
JetBrains ReSharper 7.1.3 package for Microsoft Visual Studio. For more information about ReSharper, visit http://www.jetbrains.com/resharper/. Copyright © 2003–2013 JetBrains, Inc.

Microsoft Visual Studio 2010 Professional - ENU Service Pack 1 (KB983509) KB983509
This service pack is for Microsoft Visual Studio 2010 Professional - ENU.
If you later install a more recent service pack, this service pack will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/983509.

Microsoft Visual Studio 2010 SharePoint Developer Tools 10.0.40219
Microsoft Visual Studio 2010 SharePoint Developer Tools

NuGet Package Manager 2.6.40627.9000
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Xamarin.Android 4.8.01013 (b76e8ec4)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS 1.3.250 (49348a51)
Visual Studio extension to enable development for Xamarin.iOS
Comment 3 Sebastien Pouliot 2013-09-16 20:48:42 UTC
Jon, have you verified that this is not a duplicate of bug #14696 that we looked into last week ?
Comment 4 jannic.benitz 2013-09-17 07:20:05 UTC
Typing --gsharedvt=true in "additional mtouch arguments" solved the problem.
Comment 5 Sebastien Pouliot 2013-09-17 08:11:32 UTC
Jannic, you better turn back the (default) option on inside the UI [1] and make sure it's set for every (iPhone) configuration (e.g. Debug, Release, AdHoc, AppStore).

[1] https://bugzilla.xamarin.com/show_bug.cgi?id=14696#c7

*** This bug has been marked as a duplicate of bug 14696 ***
Comment 6 jannic.benitz 2013-09-17 08:17:05 UTC
I am using Visual Studio. Where do I find this configuration?
Comment 7 Sebastien Pouliot 2013-09-17 08:19:40 UTC
I'm not sure as I do not work from Windows/VS myself. However in general the UI is keept very similar, so it should be close to your "iOS Build" options (where you can select the ARM architecture and GC).
Comment 8 Graham Moore 2013-09-17 08:22:23 UTC
Project properties-->IOS Build-->Additional Options-->Additional mtouch arguments
Comment 9 Sebastien Pouliot 2013-09-17 08:29:58 UTC
Graham, that will work but it's not the "best" place. That option should be "on" by default and, since it's part of the UI, it should be turn back on inside the UI (not using custom arguments).
Comment 10 jannic.benitz 2013-09-17 08:36:33 UTC
Created attachment 4910 [details]
iOS Build Options

There are no settings to set this by default!?
Comment 11 Graham Moore 2013-09-17 08:39:23 UTC
Hi Sebastien
No UI option for VS. I can see it in XS however.
Comment 12 Sebastien Pouliot 2013-09-17 08:53:35 UTC
Sorry it must be new in 1.4. Keep it in the extra arguments until the update is available.
Comment 13 Graham Moore 2013-09-17 08:55:38 UTC
OK no problems. Will be good to get some more Visual Studio attention.
Comment 14 softlion 2014-02-26 18:18:24 UTC
+1 using

Typing --gsharedvt=true in "additional mtouch arguments" did not solved the problem.


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) <Module>:invoke_void__this___HttpWebRequest_bool (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 unknown>:0 
	  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 /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62 
	  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[System.Net.Http.HttpResponseMessage].GetResult () [0x00000] in <filename unknown>:0 
	  at Ac.Shared.Tools.Rest+<Request>d__d.MoveNext () [0x002c2] in c:\DiskJ\projets\SHAPR\Master\ac\Ac.Shared\Tools\Rest.cs:170 
	  --- End of inner exception stack trace ---
Comment 15 Sebastien Pouliot 2014-02-26 20:36:09 UTC
This is the same exception but **not** the same stack trace, i.e. that's a different problem (not all EEE are related to generics/value-types) and likely why enabling generic value-type sharing does not work.

Please open a separate bug report and attach a self-contained test case so this can be examined. Thanks!