我正在将 MonoTouch 4.0.7 与 MonoDevelop 2.8 Beta 2 和 XCode 4 一起使用(顺便说一句,有人知道如何获得 MonoTouch 4.2 版本吗?)。我们正在尝试通过 slsvcutil 代理生成器生成的类调用 .Net Web 服务方法。
在 iPhone 模拟器上测试应用程序时,代码正常工作,我们成功连接到服务器并发送 Web 服务请求。
但是,当在设备上测试应用程序(iPhone 4 和 iOS 4.3.5)时,应用程序在调用 OpenAsynch() 方法(代理生成器生成的代码中调用的方法)时无法连接到服务器,我们得到一个奇怪的错误:
尝试在使用 --aot-only 运行时JIT 编译方法 '(wrapper delegate-begin-invoke) '(wrapper delegate-begin-invoke) :begin_invoke_IAsyncResult_ this __TimeSpan_AsyncCallback_object (System.TimeSpan,System.AsyncCallback,object)'。
我的错误堆栈:
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
有人知道这是 MonoTouch 错误还是有办法修复此崩溃?提前致谢!
- - 编辑 - -
我找到了一种解决方法:将 OpenAsync() 调用替换为 Open()。因此,我认为这是 MonoTouch 的一个限制/错误,它不支持异步调用以打开 Web 服务连接。我将在 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();
}
}