Ios HttpClient执行运行时错误:ExecutionEngineeException-正在尝试使用--aot only来JIT编译方法

Ios HttpClient执行运行时错误:ExecutionEngineeException-正在尝试使用--aot only来JIT编译方法,ios,xamarin.ios,httpclient,xamarin,Ios,Xamarin.ios,Httpclient,Xamarin,我正在使用安装了iOS 6.4.4更新的Xamarin(MAC)。My touch项目使用启用了HttpClient的PCL库。每次执行使用HttpClient的方法时,都会出现以下运行时错误: System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-invoke) <Module>:invoke_void__this___HttpWebRequest_long (Sys

我正在使用安装了iOS 6.4.4更新的Xamarin(MAC)。My touch项目使用启用了HttpClient的PCL库。每次执行使用HttpClient的方法时,都会出现以下运行时错误:

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-invoke) <Module>:invoke_void__this___HttpWebRequest_long (System.Net.HttpWebRequest,long)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.

  at System.Lightup.Call[HttpWebRequest,Int64] (System.Delegate& storage, System.Net.HttpWebRequest instance, System.String methodName, Int64 parameter) [0x00000] in <filename unknown>:0 
  at System.Lightup.Set[HttpWebRequest,Int64] (System.Delegate& storage, System.Net.HttpWebRequest instance, System.String propertyName, Int64 value) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequestLightup.SetContentLength (System.Net.HttpWebRequest instance, Int64 value) [0x00000] in <filename unknown>:0 
  at System.Net.Http.HttpWebRequest.set_ContentLength (Int64 value) [0x00000] in <filename unknown>:0 
  at System.Net.Http.HttpClientHandler.StartRequest (System.Object obj) [0x00000] in <filename unknown>:0
System.executionEngineeException:尝试JIT编译方法“(包装器委托调用):仅在使用--aot运行时调用\u void\u this\u\u HttpWebRequest\u long(System.Net.HttpWebRequest,long)”。看见http://docs.xamarin.com/ios/about/limitations 了解更多信息。
在System.Lightup.Call[HttpWebRequest,Int64](System.Delegate&storage,System.Net.HttpWebRequest实例,System.String methodName,Int64参数)[0x00000]中:0
在System.Lightup.Set[HttpWebRequest,Int64](System.Delegate&storage,System.Net.HttpWebRequest实例,System.String propertyName,Int64值)[0x00000]中:0
在System.Net.HttpWebRequestLightup.SetContentLength(System.Net.HttpWebRequest实例,Int64值)[0x00000]中:0
在System.Net.Http.HttpWebRequest.set_ContentLength(Int64值)[0x00000]中:0
位于System.Net.Http.HttpClientHandler.StartRequest(System.Object obj)[0x00000]中:0

如何解决该问题?

官方仍不支持PCL。特别是当涉及异步/等待时。同时,您可以了解我为什么这样做,并创建一个特定于平台的类库,并将源文件添加为链接(如果Visual Studio将文件从Windows资源管理器ALT拖动到VS解决方案资源管理器,并且当Xamarin Studio在目标项目外看到源文件时,会自动提供链接选项,则Visual Studio会这样做).

我知道我迟到了将近3年:)但今天我遇到了这个问题。现在支持PCL,因此我认为为这个问题添加一些附加信息可能会有所帮助

如果您在PCL项目中引用System.Net.Http,例如使用Microsoft.Net.Http NuGet包,那么您还必须将该引用添加到iOS项目中。您只需在iOS项目上安装此NuGet软件包即可

这将迫使iOS项目使用System.Net.Http dll的Mono iOS版本,而不是PCL的变体,后者可能是net45或类似的版本

我认为出现这个问题是因为System.Net.Http的net45变体使用反射来调用某些方法。请注意,该错误表示尝试了某些调用,这需要JIT编译。但是,这在iOS物理设备上是禁止的,而在iOS模拟器上则不是。iOS物理设备需要提前(aot)编译

Attempting to JIT compile method '(wrapper delegate-invoke) <Module>:invoke_callvirt_void_HttpWebRequest_bool (System.Net.HttpWebRequest,bool)'
尝试JIT编译方法(包装器委托调用):调用\u callvirt\u void\u HttpWebRequest\u bool(System.Net.HttpWebRequest,bool)'

您可以发布尝试调用此函数的代码吗?var client=new HttpClient();var content=wait client.DownloadStringAsync(“);此代码位于PCL库中,包含158个配置文件非常感谢,这解决了我的问题!我必须在我的iOS项目上安装此软件包!