json 解析错误的问题 “/”应用程序中的服务器错误。


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

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

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

源错误: 
程序集加载跟踪: 下列信息有助于确定程序集“Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”未能加载的原因。

=== 预绑定状态信息 ===
日志: DisplayName = Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
 (Fully-specified)
日志: Appbase = file:///G:/code/IronFuryServer/Route/
日志: 初始 PrivatePath = G:codeIronFuryServerRoutein
调用程序集: System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35。
===
日志: 此绑定从 default 加载上下文开始。
日志: 正在使用应用程序配置文件: G:codeIronFuryServerRouteweb.config
日志: 使用主机配置文件: C:WindowsMicrosoft.NETFramework64v4.0.30319aspnet.config
日志: 使用 C:WindowsMicrosoft.NETFramework64v4.0.30319configmachine.config 的计算机配置文件。
日志: 策略后引用: Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/24fb3432/4a6a283a/Newtonsoft.Json.DLL。
日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/24fb3432/4a6a283a/Newtonsoft.Json/Newtonsoft.Json.DLL。
日志: 尝试下载新的 URL file:///G:/code/IronFuryServer/Route/bin/Newtonsoft.Json.DLL。
警告: 比较程序集名称时发生不匹配: 主版本
错误: 未能完成程序集的安装(hr = 0x80131040)。探测终止。

解决办法,需要在config里添加

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