简体   繁体   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)

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?). 我正在使用MonoTouch 4.0.7与MonoDevelop 2.8 Beta 2和XCode 4(有人知道如何获得MonoTouch 4.2版本?)。 We are trying to call a .Net web service method through classes generated by the slsvcutil proxy generator. 我们试图通过slsvcutil代理生成器生成的类调用.Net Web服务方法。

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. 在iPhone模拟器上测试应用程序时,代码正常工作,我们成功连接到服务器并发送Web服务请求。

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: 但是,当在设备(带有iOS 4.3.5的iPhone 4)上测试应用程序时,应用程序在调用OpenAsynch()方法时无法连接到服务器(在代理生成器生成的代码中调用Method),我们得到一个奇怪的错误:

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. 尝试使用-aot-only运行JIT编译方法'(包装器委托 - 开始 - 调用)'(包装器委托 - 开始 - 调用):begin_invoke_IAsyncResult_ this __TimeSpan_AsyncCallback_object(System.TimeSpan,System.AsyncCallback,object)'。

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? 有人知道这是一个MonoTouch错误还是有办法解决这个崩溃? Thanks in advance! 提前致谢!

---- EDIT ---- ----编辑----

I found a workaround: replace the OpenAsync() call by Open(). 我找到了一个解决方法:用Open()替换OpenAsync()调用。 Thus, I think it is a limitation/bug of MonoTouch that does not support asynchronous call to open a Web service connection. 因此,我认为MonoTouch的限制/错误不支持异步调用来打开Web服务连接。 I'll enter a bug in bugzilla.xamarin.com 我将在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 believe the specific problem is the same as in this post from the Unity 3D forum: 我相信具体问题与Unity 3D论坛中的这篇文章相同:

AOT issue with += event handler syntax 带有+ =事件处理程序语法的AOT问题

As in this post, the generated async proxy code uses the += event syntax, which requires JIT compilation. 如本文所述,生成的异步代理代码使用+ =事件语法,这需要JIT编译。 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. 我没有测试过OpenAsyc,因此在解决事件处理程序问题后可能会遇到其他困难。

UPDATE UPDATE

MonoTouch (itself) is hitting one of the full-AOT limitation of MonoTouch. MonoTouch(本身)正在达到MonoTouch的完全AOT 限制之一。

The immediate workaround is to use the synchronous Open method (instead of OpenAsync method). 直接的 解决方法是使用同步Open方法(而不是OpenAsync方法)。

A bug report was opened to track this issue. 已打开错误报告以跟踪此问题。 You can add yourselves on its cc list to be updated on its progress. 您可以将自己添加到其cc列表中,以更新其进度。

暂无
暂无

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

相关问题 在设备上运行时,MonoTouch 4.2不支持System.ServiceModel.EndpointAddress()(在模拟器上运行) - MonoTouch 4.2 does not support System.ServiceModel.EndpointAddress() when running on the device (works on the simulator) Monotouch应用程序在设备中崩溃,但在模拟器中工作正常 - Monotouch application is getting crashed in device but works fine in simulator connection.OpenAsync和connection.Open之间的区别在使用Dapper QueryAsync方法时 - Difference between connection.OpenAsync and connection.Open when using Dapper QueryAsync method MonoTouch应用程序在Simulator中运行,但不在Device上运行 - MonoTouch application runs in Simulator, but not on Device MonoTouch iOS应用程序无法在设备目录中找到文件-在模拟器上工作 - MonoTouch iOS application can't find files in directory on device - works on simulator 代码在控制台应用程序中有效,但在Windows Service中运行时不起作用 - Code works in a console application, but does not work when running in windows service MonoTouch运行时测试,看它是否在模拟器中运行 - MonoTouch runtime test to see if it's running in the simulator Xamarin.ios 不适用于真正的 iOS 设备,但它适用于模拟器 - Xamarin.ios does NOT work on real iOS device but it works on Simulator MonoTouch还支持NSInvocationOperation吗? - Does MonoTouch support NSInvocationOperation yet? 从Web应用程序调用Web服务时拒绝连接时,可以从本地主机正常工作 - Getting connection refused when calling a web service from a web app works fine from localhost
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM