我正在运行一个基于ASP.NEt web API2的应用程序。我已经安装了最新的Newton.Json包。该应用程序运行在Framework 4.5.1上。然而,我观察到,每当我想运行应用程序时,我都会收到一个神秘的错误,声明如下:
Could not load file or assembly 'Newtonsoft.Json, Version=4.5.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)我称它为神秘,因为我引用了正确的Newton.Json。
请帮帮我。
发布于 2016-05-31 02:42:53
尝试转到references,search for Newtonsoft.Json,右键单击它,然后转到preferences并选择copy local。
如果您在参考资料中找不到Newtonsoft.Json,请右键单击项目并选择manage nuget package,然后搜索它
发布于 2017-03-11 23:21:39
我和Newtonsoft.Json也有同样的问题。您可以清楚地看到,在您的web.config中,您引用了版本6.0.0.0,但在您的代码中的某处,它需要4.5.0.0。因此存在版本冲突。
这意味着你的Newtonsoft.Json.dll版本是6.0.0.0,而你引用的是4.5.0.0。
你可以尝试的是,
1)绑定重定向:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json"
publicKeyToken="30ad4fe6b2a6aeed"
culture="neutral" />
<bindingRedirect oldVersion="4.5.0.0"
newVersion="6.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>这会将所有4.5版的请求重定向到6.0版
2)重装特定版本:输入试图访问4.5版本的'projectName‘
Get-项目projectName |更新-打包-reinstall Newtonsoft.Json -Version 6.0.1
出价重定向对我很管用。
祝你编码愉快!
https://stackoverflow.com/questions/21625862
复制相似问题