Search code examples
c#xamarin.iosmonodevelopjitservicestack

MonoTouch: Using ServiceStack caused JIT error?


I am using the MonoTouch build of Service Stack from https://github.com/ServiceStack/ServiceStack/tree/master/release/latest/MonoTouch

When run on a iPad, I get a JIT error. I thought MonoTouch took care of that in the build?

Attempting to JIT compile method     
'ServiceStack.Text.Json.JsonReader`1<Common.AppCategoryEnum>:GetParseFn ()' while running 
with --aot-only.

I use the DLLS:

  • ServiceStack.Common.dll
  • ServiceStack.Interface.dll
  • ServiceStack.Text.dll

And only this single call:

new JsonServiceClient ().GetAsync<MyResponse> (url, Success, Failure);

Solution

  • I am using the MonoTouch build of Service Stack from

    Those .dll are more than 3 months old and a similar issue was found and fixed one month ago.

    I get a JIT error. I thought MonoTouch took care of that in the build?

    Yes. When building for MonoTouch the AOT (ahead of time) compiler is used. It compiles everything it knows it will require at runtime.

    However sometimes the AOT compiler cannot know everything (e.g. generic virtual methods) or compile every possible variations (e.g. value types). See the section generic limitations in the documentation web site. In such case it AOT compiler might need help (a signature that will ensure the right code will be compiled, e.g. something like this).

    It can also be a bug - where a required method was not AOT'ed for some reason. When this is discovered, at runtime, an exception will occurs because the code is missing and the JIT cannot be used to provide it.