JSON.NET:不使用MonoTouch“跑出类型2的蹦床”

时间:2012-08-03 04:26:59

标签: ios json xamarin.ios trampolines

我在https://github.com/ayoung/Newtonsoft.Json尝试了JSON.NET和MonoTouch端口,但收到此序列化错误:

Ran out of trampolines of type 2 in '/private/var/mobile/Applications/A901C3E6-D9AB-44AF-AA13-6B6E44467BAE/StaffRostering.app/mscorlib.dll' (128)

Stacktrace:

at Newtonsoft.Json.Serialization.DefaultContractResolver.GetParametrizedConstructor (System.Type) [0x00009] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/DefaultContractResolver.cs:336
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type) [0x000ae] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/DefaultContractResolver.cs:310
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type) [0x000b0] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/DefaultContractResolver.cs:675
at Newtonsoft.Json.Utilities.ThreadSafeStore`2.AddValue (TKey) <0x000bf>
at Newtonsoft.Json.Utilities.ThreadSafeStore`2.Get (TKey) <0x00173>
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type) [0x00011] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/DefaultContractResolver.cs:196
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe (object) [0x00008] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:86
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter,object) [0x00011] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:70
at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter,object) [0x00012] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/JsonSerializer.cs:451
at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter,object) [0x00000] 

我也试过了RestSharp.Monotouch并得到了类似的错误:

Ran out of trampolines of type 2 in '/private/var/mobile/Applications/A901C3E6-D9AB-44AF-AA13-6B6E44467BAE/StaffRostering.app/mscorlib.dll' (128)

Stacktrace:

at RestSharp.Reflection.SafeDictionary`2.GetEnumerator () <0x000ab>
at RestSharp.PocoJsonSerializerStrategy.TrySerializeUnknownTypes (object,object&) <IL 0x0002b, 0x00247>
at RestSharp.PocoJsonSerializerStrategy.SerializeNonPrimitiveObject (object,object&) <IL 0x00010, 0x000e7>
at RestSharp.SimpleJson.SerializeValue (RestSharp.IJsonSerializerStrategy,object,System.Text.StringBuilder) <IL 0x000f7, 0x00e1b>
at RestSharp.SimpleJson.SerializeObject (object,RestSharp.IJsonSerializerStrategy) <IL 0x0000e, 0x000eb>
at RestSharp.SimpleJson.SerializeObject (object) <IL 0x00006, 0x0008f>
at RestSharp.Serializers.JsonSerializer.Serialize (object) <IL 0x00001, 0x00083>

1 个答案:

答案 0 :(得分:4)

以下是解决方案:

退出2型蹦床

如果您使用大量接口,您可能会在设备上收到此消息。您可以通过修改项目选项“iPhone Build”部分来创建更多类型2蹦床(键入IMT Thunks)。您想为Device构建目标添加额外的参数:

-aot "nimt-trampolines=512"

IMT Thunk蹦床的默认数量是128.尝试增加此数字,直到您有足够的使用接口为止。

我不知道蹦床究竟是什么......