无法加载类型'Newtonsoft.Json.Serialization.CamelCaseNamingStrategy'

时间:2019-10-11 15:24:30

标签: c# .net json json.net

我的项目最近开始引发以下错误:

Unexpected error: Could not load type 'Newtonsoft.Json.Serialization.CamelCaseNamingStrategy' from assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
   at System.Reflection.CustomAttribute._GetPropertyOrFieldData(RuntimeModule pModule, Byte** ppBlobStart, Byte* pBlobEnd, String& name, Boolean& bIsProperty, RuntimeType& type, Object& value)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
   at Newtonsoft.Json.Utilities.ReflectionUtils.GetAttributes[T](ICustomAttributeProvider attributeProvider, Boolean inherit)
   at Newtonsoft.Json.Utilities.ReflectionUtils.GetAttribute[T](ICustomAttributeProvider attributeProvider, Boolean inherit)
   at Newtonsoft.Json.Serialization.JsonTypeReflector.GetAttribute[T](Type type)
   at Newtonsoft.Json.Utilities.ThreadSafeStore`2.AddValue(TKey key)
   at Newtonsoft.Json.Utilities.ThreadSafeStore`2.Get(TKey key)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Extension.Command.ClientInitializer() in C:\project\Command.cs:line 18
in Command.Initializer

我真的不知道我可能要进行哪些更改才能使它出现。

我正在使用fody.costura捆绑我的所有依赖项,并且确保已将其捆绑。

以下是Newtonsoft.Json依赖项的属性:

Name                : Newtonsoft.Json
Aliases             : global
Copy Local          : True
Culture             : 
Description         : Json.NET is a popular high-performance JSON framework for .NET
Embed Interop Types : False
File Type           : Assembly
Identity            : Newtonsoft.Json
Path                : C:\project\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll
Resolved            : True
Runtime Version     : v4.0.30319
Specific Version    : True
Strong Name         : True
Version             : 12.0.0.0

我的项目是.NET Framework 4.6.1类库项目。

关于可能是什么问题的任何建议?

谢谢!

0 个答案:

没有答案