C# 无法加载类型';Newtonsoft.Json.Serialization.CamelCaseNamingStrategy';
我的项目最近开始抛出以下错误:C# 无法加载类型';Newtonsoft.Json.Serialization.CamelCaseNamingStrategy';,c#,.net,json,json.net,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
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
我的项目是一个.NETFramework 4.6.1类库项目
关于可能出现的问题有什么建议吗
谢谢 请看这个答案谢谢。但是加载程序集似乎没有任何问题。只是程序集中的类型。异常是否有内部异常?该类必须依赖于程序集中无法加载的类型。检查Fody是否也嵌入了Newtonsoft的所有依赖项。我在我的问题中添加了完整的例外情况。您是否能够提供一个?那会让我们更容易帮助你。(至少看起来12.0.2中有这种类型…)请参阅此答案谢谢。但是加载程序集似乎没有任何问题。只是程序集中的类型。异常是否有内部异常?该类必须依赖于程序集中无法加载的类型。检查Fody是否也嵌入了Newtonsoft的所有依赖项。我在我的问题中添加了完整的例外情况。您是否能够提供一个?那会让我们更容易帮助你。(至少看起来12.0.2中有这样的类型…)