我已经在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>

最佳答案

解决方法如下:

跑出了2型的蹦床

如果您使用频繁的界面,则可能会在设备上收到此消息。您可以通过修改项目选项“iPhone Build”部分来创建更多的2型蹦床(IMT Thunks类型)。您要为设备构建目标添加其他参数:

-aot "nimt-trampolines=512"

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

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

关于ios - JSON.NET:无法与MonoTouch一起使用“用尽了2型蹦床”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11789261/

10-11 08:50