MonoTouch: Using ServiceStack caused a JIT error?

I use MonoTouch to build Service Stack from https://github.com/ServiceStack/ServiceStack/tree/master/release/latest/MonoTouch

When I launch on iPad, I get a JIT error. I thought MonoTouch took care of this in the assembly?

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

I am using DLLS:

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

And just this one call:

 new JsonServiceClient ().GetAsync<MyResponse> (url, Success, Failure); 
+1
source share
2 answers

I am using the MonoTouch Service Stack assembly from

Those .dlls are older than 3 months and a similar problem was found and fixed a month ago.

I get a JIT error. I thought MonoTouch took care of this in the assembly?

Yes. When creating for MonoTouch, AOT (ahead of time) is used. He compiles everything that he knows will be needed at runtime.

However, sometimes the AOT compiler cannot know everything (for example, general virtual methods) or compile all possible options (for example, value types). See the General Restrictions section of the documentation website. In this case, the AOT compiler may need help (a signature that will compile the correct code, for example, something like this ).

It could also be a mistake - where for some reason the requested method was not AOT'ed. When this is detected, an exception is thrown at runtime because the code is missing and the JIT cannot be used to provide it.

+4
source

I know that this topic was created long ago, but I find a little workaround here and there just call var dummy = new JsonSerializer () in AppDelegate in the FinishedLaunching method.

+1
source

All Articles