MonoTouch 不支持在设备上运行时打开 Web 服务连接的 OpenAsync 方法(适用于模拟器)
我正在将 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 编译方法 '(wrapper delegate-begin-invoke) '(wrapper delegate-begin-invoke) :begin_invoke_IAsyncResult_this__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();
}
}
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();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信具体问题与 Unity 3D 论坛的这篇文章相同:
+= 事件处理程序语法的 AOT 问题
如本文中所示,生成的异步代理代码使用 += 事件语法,这需要 JIT 编译。我已经确认帖子中的修复解决了该问题。
我尚未测试 OpenAsyc,因此在解决事件处理程序问题后您可能会遇到其他困难。
I believe the specific problem is the same as in this post from the Unity 3D forum:
AOT issue with += event handler syntax
As in this post, the generated async proxy code uses the += event syntax, which requires JIT compilation. I have confirmed that the fix in the post solves that problem.
I haven't tested OpenAsyc, so you may run into additional difficulties after solving the event handler issue.
更新
MonoTouch(本身)遇到了完整 AOT 限制 之一MonoTouch 的。
立即 解决方法是使用同步Open方法(而不是OpenAsync 方法)。
我们已打开错误报告来跟踪此问题。您可以将自己添加到其抄送列表中,以了解其进度的更新。
UPDATE
MonoTouch (itself) is hitting one of the full-AOT limitation of MonoTouch.
The immediate workaround is to use the synchronous Open method (instead of OpenAsync method).
A bug report was opened to track this issue. You can add yourselves on its c.c. list to be updated on its progress.