System.ExecutionEngineException:仅在设备上的调试模式下尝试JIT编译方法(MonoTouch)

时间:2012-10-11 10:29:04

标签: ios xamarin.ios jit aot

我有以下方法:

ApiResponse<T> PostMultipart<T>(string uploadUrl, NameValueCollection formParamters, params UploadFile[] uploadFiles);

UploadFile只是一个Poco:

public class UploadFile
{
    public string FilePath { get; set; }
    public string ContentType { get; set; }
    public string ParameterName { get; set; }
}

通过调用该方法,在模拟器上使用“Debug | iPhoneSimulator”和使用iOS 5.1.1和“Release | iPhone”的iPod Touch上运行良好。

但是当我开始在设备上调试应用程序(“Debug | iPhone”)时,我得到以下异常:

  

System.ExecutionEngineException:在使用--aot-only运行时尝试JIT编译方法'Xyz.Api.ApiClient:PostMultipart(string,System.Collections.Specialized.NameValueCollection,Xyz.Api.UploadFile [])'。有关详细信息,请参阅http://docs.xamarin.com/ios/about/limitations

我在链接页面上看不到任何相关信息。我无法理解为什么只有在手机上调试时才会出现这种行为。

其他人是否能够理解这里发生了什么? :)

1 个答案:

答案 0 :(得分:6)

您的代码示例不够完整(要复制)但很可能是,因为您的<T>是值类型(例如int,枚举... )。

AOT编译器难以为无法共享代码的值类型生成代码(就像任何引用类型一样)。解决方法包括:

  • 暗示你所需要的AOT编译器(确保<T>已知,并为你正在使用的值类型生成代码);

  • 使用引用类型(例如string)代替值类型(例如int

  

我无法理解为什么只有在手机上调试时才会出现这种行为。

iOS设备不允许使用JIT代码(Apple的限制),因此使用了AOT。 iOS模拟器没有此限制,因此使用JIT(因为它比AOTing代码更快很多)。

相关问题