当我最近将Xamarin Forms项目中的Newtonsoft.Json包升级到v8.0.1时,我开始看到一个奇怪的异常。当我尝试反序列化对象时,我在三个不同的项目中看到了同样的问题。每次调用反序列化都不会发生这种情况,但它与特定调用一致。
这些都是代码没有改变的项目,我不相信JSON已经改变,所以这对我来说就像Newtonsoft或Xamarin的问题一样?
还有其他人看到这个问题吗?
例外详细信息:
Newtonsoft.Json.Utilities.TypeExtensions.TestAccessibility (System.Reflection.MemberInfo成员,BindingFlags bindingFlags) [0x0003f] in:0 at Newtonsoft.Json.Utilities.TypeExtensions + LT;> c__DisplayClass34_0.b__0 (System.Reflection.MemberInfo m)[0x00013] in:0
at System.Linq.Enumerable + WhereListIterator1[TSource].MoveNext () [0x00048] in /Users/builder/data/lanes/2377/73229919/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:232 at System.Linq.Buffer
1 [TElement] .. ctor(IEnumerable1 source) [0x00083] in /Users/builder/data/lanes/2377/73229919/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:2570 at System.Linq.Enumerable.ToArray[TSource] (IEnumerable
1 source) [0x00011] in /Users/builder/data/lanes/2377/73229919/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System.Core/System/Linq/Enumerable的.cs:830 at Newtonsoft.Json.Utilities.TypeExtensions.GetMember(System.Type type,System.String成员,BindingFlags bindingFlags)[0x00030] in :0点 Newtonsoft.Json.Utilities.TypeExtensions.GetMember(System.Type type, System.String name,MemberTypes memberType,BindingFlags bindingFlags) [0x0000d] in:0 at Newtonsoft.Json.Utilities.ReflectionUtils.GetMemberInfoFromType (System.Type targetType,System.Reflection.MemberInfo memberInfo) [0x00066] in:0 at Newtonsoft.Json.Serialization.JsonTypeReflector.GetAttribute [T] (System.Reflection.MemberInfo memberInfo)[0x0005f] in:0 at Newtonsoft.Json.Serialization.JsonTypeReflector.GetAttribute [T] (System.Object provider)[0x0001b] in:0 at Newtonsoft.Json.Serialization.DefaultContractResolver.GetSerializableMembers (System.Type objectType)[0x000cf] in:0 at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties (System.Type类型,MemberSerialization memberSerialization)[0x00000] in:0 at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType)[0x00035] in:0 at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType)[0x000c9] in:0 at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type类型)[0x00038] in:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe (System.Type类型)[0x00005] in:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (IList列表,Newtonsoft.Json.JsonReader读者, Newtonsoft.Json.Serialization.JsonArrayContract合同, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id)[0x00052] in:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader,System.Type objectType, Newtonsoft.Json.Serialization.JsonContract合同, Newtonsoft.Json.Serialization.JsonProperty成员,System.Object existingValue,System.String id)[0x000dc] in:0
在 Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader,System.Type objectType, Newtonsoft.Json.Serialization.JsonContract合同, Newtonsoft.Json.Serialization.JsonProperty成员, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue)[0x0007f] in:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty属性, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader,System.Object target)[0x00061] in :0点 Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject,Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract合约, Newtonsoft.Json.Serialization.JsonProperty成员,System.String id) [0x00220] in:0
答案 0 :(得分:0)
这是一个已知的错误。
使用7.0.1直到8.0.2发布 - https://github.com/JamesNK/Newtonsoft.Json/issues/771