I am using MonoTouch 4.0.7 with MonoDevelop 2.8 Beta 2 and XCode 4 (by the way someone know how to get MonoTouch 4.2 version?). We are trying to call a .Net web service method through classes generated by the slsvcutil proxy generator.
When testing the app on the iPhone simulator, the code is working and we succeed to connect to the server and send web services requests.
However, when testing the app on a device (iPhone 4 with iOS 4.3.5), the app fails to connect to the server when calling OpenAsynch() method (Method called in the code generated by the proxy generator), we get a strange error:
Attempting to JIT compile method '(wrapper delegate-begin-invoke) '(wrapper delegate-begin-invoke) :begin_invoke_IAsyncResult_this__TimeSpan_AsyncCallback_object (System.TimeSpan,System.AsyncCallback,object)' while running with --aot-only.
My 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
Someone know if it is a MonoTouch bug or if there is a way to fix this crash? Thanks in advance!
---- EDIT ----
I found a workaround: replace the OpenAsync() call by Open(). Thus, I think it is a limitation/bug of MonoTouch that does not support asynchronous call to open a Web service connection. I'll enter a bug in bugzilla.xamarin.com
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);
//m_notificationMgrClient.OpenAsync();
m_notificationMgrClient.Open();
DoGetLastMessageId();
}
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
DoGetLastMessageId();
}
}