繁体   English   中英

在设备上运行时,MonoTouch不支持OpenAsync方法打开Web服务连接(在模拟器上工作)

[英]MonoTouch does not support OpenAsync method for opening a web service connection when running on the device (works on the simulator)

我正在使用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()方法时无法连接到服务器(在代理生成器生成的代码中调用Method),我们得到一个奇怪的错误:

尝试使用-aot-only运行JIT编译方法'(包装器委托 - 开始 - 调用)'(包装器委托 - 开始 - 调用):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错误还是有办法解决这个崩溃? 提前致谢!

----编辑----

我找到了一个解决方法:用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();
  }
}

我相信具体问题与Unity 3D论坛中的这篇文章相同:

带有+ =事件处理程序语法的AOT问题

如本文所述,生成的异步代理代码使用+ =事件语法,这需要JIT编译。 我已经确认帖子中的修复解决了这个问题。

我没有测试过OpenAsyc,因此在解决事件处理程序问题后可能会遇到其他困难。

UPDATE

MonoTouch(本身)正在达到MonoTouch的完全AOT 限制之一。

直接的 解决方法是使用同步Open方法(而不是OpenAsync方法)。

已打开错误报告以跟踪此问题。 您可以将自己添加到其cc列表中,以更新其进度。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM