我正在使用MonoTouch 4.0.7和MonoDevelop 2.8 Beta 2和XCode 4(有人知道如何获得MonoTouch 4.2版本?)。我们试图通过slsvcutil代理生成器生成的类调用.Net Web服务方法。
在iPhone模拟器上测试应用程序时,代码正常运行,我们成功连接到服务器并发送Web服务请求。
但是,在设备上测试应用程序(带有iOS 4.3.5的iPhone 4)时,应用程序在调用OpenAsynch()方法(代理生成器生成的代码中调用的方法)时无法连接到服务器,我们得到一个奇怪的错误:
尝试JIT编译方法'(包装器委托 - 开始 - 调用)'(包装器委托 - 开始 - 调用) :begin_invoke_IAsyncResult_ 此 __ TimeSpan_AsyncCallback_object(System.TimeSpan,System.AsyncCallback,object)'在使用--aot-only运行时。
我的错误堆栈:
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错误还是有办法解决这个崩溃?提前谢谢!
----编辑----
我找到了一种解决方法:用Open()替换OpenAsync()调用。因此,我认为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();
}
}
答案 0 :(得分:1)
我认为具体问题与Unity 3D论坛中的这篇文章相同:
AOT issue with += event handler syntax
在本文中,生成的异步代理代码使用+ =事件语法,这需要JIT编译。我已经确认帖子中的修复解决了这个问题。
我还没有测试过OpenAsyc,所以在解决事件处理程序问题后你可能会遇到其他困难。
答案 1 :(得分:0)
<强>更新强>
MonoTouch(本身)正在击中MonoTouch的全AOT limitation之一。
立即 workaround是使用同步打开方法(而不是 OpenAsync 方法)。
已打开bug report来跟踪此问题。您可以在 c.c。列表中添加自己,以便更新其进度。