首页 > Web开发 > 详细

无法加载文件或程序集“Newtonsoft.Json”或它的某一个依赖项

时间:2019-03-21 22:57:46      阅读:135      评论:0      收藏:0      [点我收藏+]

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

有时候我们创建了一个类库,我们项目又引用了这个类库,需要我们把Newtonsoft.Json统一化。

对每个引用Newtonsoft.Json的项目做下面的处理:

①删除bin下面的Newtonsoft.Json.dll

②重新nuget引用Newtonsoft.Json到一个版本(看实际情况,一般是最新)

③添加我们的依赖,然后重新生成

 

 version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="4.5.0.0" />   <!-- newVersion 一般都是你在nuget种引用的版本的  -->  
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

 

特殊情况:

如果你这样做了还是报错,列如:

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

执行上面的步骤,把Newtonsoft.Json引用到报错的版本

 

无法加载文件或程序集“Newtonsoft.Json”或它的某一个依赖项

原文:https://www.cnblogs.com/Sea1ee/p/10575356.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!