ServiceStack JIT Error on MonoTouch

I saw the previous SO question here , which discussed a similar (identical?) Problem, but there was no answer there that could satisfy my problem.

My environment:

  MonoDevelop 3.0.3.2
 Installation UUID: ????????
 Runtime:
     Mono 2.10.9 (tarball)
     GTK 2.24.10
     GTK # (2.12.0.0)
     Package version: 210090011
 Mono for Android not installed
 Apple Developer Tools:
      Xcode 4.3.3 (1178)
      Build 4E3002
 Monotouch: 5.2.12
 Build information:
     Release ID: 30003002
     Git revision: 7bf6ac0ca43c1b12703176ad9933c3484c05c84c-dirty
     Build date: 2012-06-16 04: 36: 10 + 0000
     Xamarin addins: 62ad7268d38c2ece7e00dc32960bd3bdab8fec38
 Operating System:
     Mac OS X 10.7.4
     Darwin NEWTON.local 11.4.0 Darwin Kernel Version 11.4.0
         Mon Apr 9 19:32:15 PDT 2012
         root: xnu-1699.26.8 ~ 1 / RELEASE_X86_64 x86_64

My code (Ping and PingResponse is a DTO in my own ServiceModel library):

Ping request = new Ping { LoginInfo = new IMDSSWebService_SS.ServiceModel.ClientLoginInfo { UserName="guest", Password="guest", ClientPlatform="iOS", ClientVersion="1.5", InstanceUID="uid1"} }; var response = _appDel.ServiceClient.Send<IMDSSWebService_SS.ServiceModel.PingResponse>(request); 

ServiceStack Libraries:

 ServiceStack.Common.Monotouch.dll (built from git src) ServiceStack.Interfaces.Monotouch.dll (built from git src) ServiceStack.Text.Monotouch (built from git src) 

An exception:

  System.ExecutionEngineException has been thrown

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

 System.ExecutionEngineException: Attempting to JIT compile method 'ServiceStack.Text.Json.JsonReader`1: GetParseFn ()' while running with --aot-only.

   at ServiceStack.Text.Json.JsonReader.GetParseFn (System.Type type) [0x00000] in: 0
   at ServiceStack.Text.Json.JsonTypeSerializer.GetParseFn (System.Type type) [0x00000] in: 0
   at ServiceStack.Text.Common.TypeAccessor.Create (ITypeSerializer serializer, ServiceStack.Text.TypeConfig typeConfig, System.Reflection.PropertyInfo propertyInfo) [0x00000] in: 0
   at ServiceStack.Text.Common.DeserializeType`1 [ServiceStack.Text.Json.JsonTypeSerializer] .GetParseMethod (ServiceStack.Text.TypeConfig typeConfig) [0x00000] in: 0
   at ServiceStack.Text.Common.JsReader`1 [ServiceStack.Text.Json.JsonTypeSerializer] .GetParseFn [PingResponse] () [0x00000] in: 0
   at ServiceStack.Text.Json.JsonReader`1 [IMDSSWebService_SS.ServiceModel.PingResponse] .. cctor () [0x00000] in: 0

I tried calling JsConfig.RegisterForAot (), but that didn't change anything. I also tried various permutations of Link SDK Only, Link All, Link None, but everything failed either with the above exception, or it wasn’t created at all, see below.

  Simulator / Debug - Works Fine
 Simulator / Release - Works Fine
 iPhone / Debug - Exception Above
 iPhone / Release - Doesn't even build.  (will create a separate SO question)
+2
source share
1 answer

I added a type registration function to ServiceStack.Text.Monotouch.JsConfig.cs, which allows you to register your own DTOs to compile AOT. A request to access the main line of ServiceStack requires a transfer request, so this should be done soon.

Change JsConfig Code

You need to register all of your DTO response types that are not standard C # types (string, int, etc.). My PingResponse DTO includes a StatusEnum enumeration, so I need to register both before I can parse the response without throwing a JIT exception. Using the patch above, I would name the following in my Monotouch application:

 JsConfig.RegisterForAot(); JsConfig.RegisterTypeForAot<PingResponse>(); JsConfig.RegisterTypeForAot<StatusEnum>(); 

This can become very dirty for complex DTOs. Hopefully someone (maybe I can, if time permits) can come up with an automated way to detect all types in your DTO that needs to be registered? Maybe a reflection?

+4
source

All Articles