【发布时间】:2016-05-28 07:42:42
【问题描述】:
每次运行项目时都会出现以下异常:
“System.IO.FileLoadException”类型的异常发生在 mscorlib.dll 但未在用户代码中处理 附加信息:无法加载文件或程序集“Newtonsoft.Json,版本=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)
我尝试了几乎所有可以在网上找到的解决方案。
我的 packages.config 文件:
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net451" />
and this in web.config file:
<assemblyIdentity name="Newtonsoft.Json" PublicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="5.0.8"/>
</dependentAssembly>
我什至使用以下命令来更新/重新安装 json.net:
update-package Newtonsoft.Json -reinstall
update-package Newtonsoft.Json
我还能尝试什么?
【问题讨论】:
-
我不确定,但也没有用。
-
我刚刚检查过,Json.NET 8.0.2
typeof(JsonSerializer).Assembly.FullName有Version=8.0.0.0。所以试一试吧。 -
另见stackoverflow.com/questions/22685530/…。当然,该答案中的版本号不适合 Json.NET 8.0.2。
-
您对版本号的看法是正确的,当我尝试重新安装时收到此消息:Successfully added 'Newtonsoft.Json 8.0.2' to Prodb1.但异常仍然会在运行时出现。
标签: c# .net json.net fileloadexception