Bug 962 - OpenAsynch() call to open a Web service connection is not supported when compiling on the device (works in the simulator)
Summary: OpenAsynch() call to open a Web service connection is not supported when comp...
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-09-21 12:03 UTC by nicolas.dougoud
Modified: 2015-04-16 13:41 UTC (History)
6 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 nicolas.dougoud 2011-09-21 12:03:53 UTC
It seems that MonoTouch does not support asynchronous call to open a Web service connection when compiling on the device (works well on the simulator). 

The following lines:

m_notificationMgrClient.OpenCompleted += new System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(NotificationMgrClient_OpenCompleted);

Gives a crash on the device with the following error stack:

Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-begin-invoke) <Module>:begin_invoke_IAsyncResult__this___TimeSpan_AsyncCallback_object (System.TimeSpan,System.AsyncCallback,object)' while running with --aot-only.
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.OnBeginOpen (TimeSpan timeout, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.CommunicationObject.BeginOpen (TimeSpan timeout, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0 
at System.ServiceModel.Channels.CommunicationObject.BeginOpen (System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0 
at System.ServiceModel.ClientBase`1+ChannelBase`1[ICommandMgr,ICommandMgr].System.ServiceModel.ICommunicationObject.BeginOpen (System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0 
at System.ServiceModel.ClientBase`
1[ICommandMgr].System.ServiceModel.ICommunicationObject.BeginOpen (System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0 
at CommandMgrClient.OnBeginOpen (System.Object[] inValues, System.AsyncCallback callback, System.Object asyncState) [0x00000] in CommandMgrStaticProxyClient.cs:1156
 at System.ServiceModel.ClientBase`1[ICommandMgr].InvokeAsync (System.ServiceModel.BeginOperationDelegate beginOperationDelegate, System.Object[] inValues, System.ServiceModel.EndOperationDelegate endOperationDelegate, System.Threading.SendOrPostCallback operationCompletedCallback, System.Object userState) [0x00000] in <filename unknown>:0 
at CommandMgrClient.OpenAsync (System.Object userState) [0x00057] in CommandMgrStaticProxyClient.cs:1193 

My code which is now working:

 private void DoNotificationMgrOpenAsync(string address, int port)
      this.SystemUIHandler.LogInfo(">>>>>> NotificationMgr Open");
      m_notificationMgrClient = new NotificationMgrClient(
        new System.ServiceModel.BasicHttpBinding() { Namespace = "http://schema.dartfish.com/2011/05/RemoteControl" },
        new System.ServiceModel.EndpointAddress(
          string.Format(System.Globalization.CultureInfo.InvariantCulture, "http://{0}:{1}/Dartfish/RemoteControlServices/",
          address, port)));
      //m_notificationMgrClient.OpenCompleted += new System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(NotificationMgrClient_OpenCompleted);

    void NotificationMgrClient_OpenCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
      this.SystemUIHandler.LogInfo("<<<<<< NotificationMgr Open");
      System.Diagnostics.Debug.Assert(m_notificationMgrClient != null);
      if (m_notificationMgrClient != null)
        m_notificationMgrClient.OpenCompleted -= NotificationMgrClient_OpenCompleted;
        // init messageId
Comment 2 Rolf Bjarne Kvinge [MSFT] 2015-04-16 13:41:56 UTC
There have been very many AOT improvements since this bug was filed, so I believe it's fixed now.