关于项目中多版本Newtonsoft.Json.dll处理方案

现象

在项目处理过程中经常碰到:

Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, 
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest 
definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

,因为这个版本比较多,如果项目中引用其他新的dll后,新的dll可能用到的Newtonsoft版本不一样,造成系统无法运行。

错误

碰到这个问题后,导致系统json的解析出错,有时候会造成无缘无故的问题,前端的对象就无法获取。

解决方案

   1、升级项目的Newtonsoft.Json.dll版本到最新
   2、web.config中设置, 
        <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" /><!--兼容之前的版本->
    <codeBase version="4.0.0.0" href="Newtonsoft.Json\4.0\Newtonsoft.Json.dll" />
  </dependentAssembly>
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

星海设计

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值