未能加载文件或程序集“Newtonsoft.Json”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)

报错信息:

“/”应用程序中的服务器错误。
未能加载文件或程序集“Newtonsoft.Json”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)

未改之前

 <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
 </dependentAssembly>

按照网上的方法,在引用中找到 Newtonsoft.Json 右击属性,与原配置文件 web.config 中写的配置不一致

改后

 <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
 </dependentAssembly>

保存web.config 执行,正常情况这个时候就可以正常执行了

而我再次出现问题,问题如下

“/”应用程序中的服务器错误。
找不到方法:“Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)”。

 出现这种情况请下载比较新的版本 

  如: 6.0 版本 Newtonsoft.Json.bll

引用,重新修改配置文件中Newtonsoft.Json的版本号,保存执行,解决问题


原文地址:https://www.cnblogs.com/dyd520/p/14693993.html