现象
在项目处理过程中经常碰到:
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>