【发布时间】:2015-04-13 17:06:39
【问题描述】:
使用时
var obj = JsonConvert.DeserializeObject(soapResponse);
它没有给 obj 赋值。
在 xamarin android 上运行良好,但在 xamarin ios 上显示错误。
{System.TypeLoadException:无法从程序集“mscorlib,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”加载类型“System.Reflection.Emit.DynamicMethod”。 在 Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator (System.Type createdType) [0x00000] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\DefaultContractResolver.cs:685 在 Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract 合同) [0x0008b] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\DefaultContractResolver.cs :716 在 Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x00007] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\DefaultContractResolver.cs:361 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\DefaultContractResolver.cs:1013 中的 Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x00100] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\DefaultContractResolver.cs:242 中的 Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(System.Type 类型)[0x0003e] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:130 中的 Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe(System.Type 类型)[0x0000b] 在 Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x0000e] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json \序列化\JsonSerializerInternalReader.cs:138 在 Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00047] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json\JsonSerializer.cs: 710 在 Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json\JsonSerializer.cs: 689 在 Newtonsoft.Json.JsonConvert.DeserializeObject(System.String 值,System.Type 类型,Newtonsoft.Json.JsonSerializerSettings 设置)[0x0002d] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json \JsonConvert.cs:846 在 Newtonsoft.Json.JsonConvert.DeserializeObject[Object] (System.String 值,Newtonsoft.Json.JsonSerializerSettings 设置)[0x00000] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json\JsonConvert .cs:805 在 Newtonsoft.Json.JsonConvert.DeserializeObject[Object](System.String 值)[0x00000] 在 c:\Development\Releases\Json\Working\Newtonsoft.Json\Src\Newtonsoft.Json\JsonConvert.cs:742 在 TrxServices.Views.Login+d__21.MoveNext () [0x00372] in d:\DAta D Drive\SelfDemo\TrxServices\TrxServices\TrxServices\Views\Login.cs:300 }
【问题讨论】:
-
iOS禁止动态代码生成,限制了Reflection.Emit的使用
-
这看起来像你正在反序列化从登录调用到服务器的响应,你的 json 是什么样的?
DeserializeObject与您的代码中的字面意思一样吗?因为它可能会从类型参数中受益......分享一些代码和数据,而不仅仅是堆栈跟踪
标签: xamarin xamarin.forms