【问题标题】:ServiceStack JIT Error on MonoTouchMonoTouch 上的 ServiceStack JIT 错误
【发布时间】:2012-07-08 18:31:16
【问题描述】:

我之前看到过 SO Question here 讨论了一个类似(相同?)的问题,但那里没有可以满足我的问题的答案。

我的环境:

MonoDevelop 3.0.3.2 安装UUID:????????? 运行: 单声道 2.10.9(压缩包) GTK 2.24.10 GTK# (2.12.0.0) 包版本:210090011 未安装适用于 Android 的 Mono 苹果开发者工具: Xcode 4.3.3 (1178) 构建 4E3002 单点触控:5.2.12 构建信息: 发行编号:30003002 Git 修订:7bf6ac0ca43c1b12703176ad9933c3484c05c84c-dirty 构建日期:2012-06-16 04:36:10+0000 Xamarin 插件:62ad7268d38c2ece7e00dc32960bd3bdab8fec38 操作系统: Mac OS X 10.7.4 达尔文 NEWTON.local 11.4.0 达尔文内核版本 11.4.0 2012 年 4 月 9 日星期一 19:32:15 PDT 根:xnu-1699.26.8~1/RELEASE_X86_64 x86_64

我的代码(Ping 和 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 已被抛出 在使用 --aot-only 运行时尝试 JIT 编译方法“ServiceStack.Text.Json.JsonReader`1:GetParseFn ()”。 System.ExecutionEngineException:在使用 --aot-only 运行时尝试 JIT 编译方法“ServiceStack.Text.Json.JsonReader`1:GetParseFn ()”。 在 ServiceStack.Text.Json.JsonReader.GetParseFn(System.Type 类型)[0x00000] 中:0 在 ServiceStack.Text.Json.JsonTypeSerializer.GetParseFn(System.Type 类型)[0x00000] 中:0 在 ServiceStack.Text.Common.TypeAccessor.Create(ITypeSerializer 序列化程序,ServiceStack.Text.TypeConfig typeConfig,System.Reflection.PropertyInfo propertyInfo)[0x00000] 在:0 在 ServiceStack.Text.Common.DeserializeType`1[ServiceStack.Text.Json.JsonTypeSerializer].GetParseMethod (ServiceStack.Text.TypeConfig typeConfig) [0x00000] in :0 在 ServiceStack.Text.Common.JsReader`1[ServiceStack.Text.Json.JsonTypeSerializer].GetParseFn[PingResponse] () [0x00000] in :0 在 ServiceStack.Text.Json.JsonReader`1[IMDSSWebService_SS.ServiceModel.PingResponse]..cctor () [0x00000] in :0

我确实尝试调用 JsConfig.RegisterForAot(),但这并没有改变任何东西。我还尝试了 Link SDK Only、Link All、Link None 的各种排列,但都失败了,或者出现上述异常,或者根本没有构建,见下文。

模拟器/调试 - 工作正常 模拟器/发布 - 工作正常 iPhone/调试 - 上面的异常 iPhone/Release - 甚至不构建。 (将创建一个单独的 SO 问题)

【问题讨论】:

    标签: xamarin.ios servicestack


    【解决方案1】:

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

    JsConfig Code Change

    您需要注册所有非标准 C# 类型(字符串、整数等)的响应 DTO 类型。我的PingResponse DTO 包含一个StatusEnum 枚举,因此我必须先注册两者,然后才能解析响应而不引发 JIT 异常。使用上面的补丁,我会在我的 Monotouch 应用程序中调用以下代码:

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

    对于复杂的 DTO,这可能会变得非常混乱。希望有人(如果时间允许,也许我会)能想出一种自动方法来发现 DTO 中应该注册的所有类型?也许是反射?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-15
      相关资源
      最近更新 更多