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

asp*_*net 6 jit xamarin.ios aot ios

我有以下方法:

ApiResponse<T> PostMultipart<T>(string uploadUrl, NameValueCollection formParamters, params UploadFile[] uploadFiles);
Run Code Online (Sandbox Code Playgroud)

UploadFile只是一个Poco:

public class UploadFile
{
    public string FilePath { get; set; }
    public string ContentType { get; set; }
    public string ParameterName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

通过调用该方法,在模拟器上使用"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.

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

别人能够理解这里发生了什么吗?:)

pou*_*pou 6

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

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

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

  • 使用引用类型(例如a string)而不是值类型(例如a int)

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

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