Ian Vink
Ian Vink

Reputation: 68750

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:

And only this single call:

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

Upvotes: 1

Views: 491

Answers (2)

Ronny
Ronny

Reputation: 105

I know it has been a long time this thread was created but I somewhat find here and there a workaround just call var dummy = new JsonSerializer() in the AppDelegate in the FinishedLaunching method.

Upvotes: 1

poupou
poupou

Reputation: 43553

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.

Upvotes: 4

Related Questions