MonoTouch: Using ServiceStack caused JIT error?

眉间皱痕 提交于 2019-12-11 11:06:54

问题


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);

回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/10094507/monotouch-using-servicestack-caused-jit-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!