2012-07-08 44 views
2

我曾见过以前的SO Question here讨论过类似(相同?)问题,但没有答案可以解决我的问题。MonoTouch上的ServiceStack JIT错误

我的环境:

 
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 

我的代码(平& PingResponse是在我自己的ServiceModel库的DTO):

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库:

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

例外:

 
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 

我没有尝试调用JsConfig.RegisterForAot(),但没有改变任何东西。我也试过了各种各样的Link SDK Only,Link All,Link None,但都失败了,或者上面的例外,或者根本没有构建,见下文。

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

回答

4

我加了一个类型注册功能ServiceStack.Text.Monotouch.JsConfig.cs,让您注册您的自定义的DTO的AOT编译。有一个对ServiceStack主线的请求,所以这应该很快就会出现。

JsConfig Code Change

您需要注册您的所有响应DTO类型不是标准的C#类型(字符串,整数等)。我的PingResponse DTO包括一个StatusEnum枚举,所以我必须先注册两个,然后才能解析响应而不抛出JIT异常。使用上面的补丁,我会打电话下面我MonoTouch的应用程序:

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

这可能会获得复杂的DTO非常的混乱。希望有人(也许我会如果时间允许的话)可以想出一个自动化的方式来发现你的DTO中应该注册的所有类型?也许反思?

+0

你应该接受这个问题:) – mythz 2012-07-09 19:06:34