System.ExecutionEngineException: attempt to use the JIT compilation method only in debug mode on the device (MonoTouch)

I have the following method:

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

UploadFile is just Poco:

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

By calling this method, each of them works fine on a simulator with "Debug | iPhoneSimulator" and on my iPod Touch with iOS 5.1.1 with "Release | iPhone".

But when I start debugging the application on the device ("Debug | iPhone"), I get the following exception:

System.ExecutionEngineException: attempted by the JIT compilation method "Xyz.Api.ApiClient: PostMultipart (string, System.Collections.Specialized.NameValueCollection, Xyz.Api.UploadFile [])" while working with -aot-only. See http://docs.xamarin.com/ios/about/limitations for more details.

I do not see any relevant information on the linked page. And I can’t understand why this behavior only occurs when debugging on the phone.

Can anyone else understand what is going on here? :)

+6
source share
1 answer

The example of your code is not enough for duplication, but this is most likely because your <T> is a type value (e.g. int , enumeration ...).

The AOT compiler has difficulty creating code for value types where the code cannot be shared (for example, for any reference type). The workaround includes:

  • AOT compiler hint about what you need (providing <T> known and code is generated for the types of values ​​you use);

  • using a reference type (e.g. a string ) instead of a value type (e.g. int )

And I can’t understand why this behavior only occurs when debugging on the phone.

IOS devices do not allow the use of JIT code (Apple limitation), so AOT is used. The iOS simulator does not have this limitation, therefore JIT is used (because it is a lot faster than the AOTing code).

+6
source

Source: https://habr.com/ru/post/927445/


All Articles