无法加载文件或程序集“Newtonsoft.Json,版本=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed" [英] Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

查看:16
本文介绍了无法加载文件或程序集“Newtonsoft.Json,版本=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误

System.IO.FileLoadException:无法加载文件或程序集'Newtonsoft.Json,版本=4.5.0.0,文化=中性,PublicKeyToken=30ad4fe6b2a6aeed' 或其依赖项之一.这定位的程序集的清单定义与程序集不匹配参考.(来自 HRESULT 的异常:0x80131040)

System.IO.FileLoadException : 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)

对于我的 CI 构建

我尝试过的解决方案

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

它也不起作用

推荐答案

在包管理器控制台中执行:Update-Package –reinstall Newtonsoft.Json.

In package manager console execute: Update-Package –reinstall Newtonsoft.Json.

更新

我最初将此作为评论发布,但正如@OwenBlacker 建议的那样,我将其放在这里:

如果执行此操作后仍然出现错误,那么最终对我有用的是我从我的 .config 文件中删除了 Json.Net 的 <dependentAssembly> 部分.如果它不存在,则重新安装会将其带回来,显然您需要将其删除.直到包本身有一个正常的解决方案,恐怕这个手动步骤是必须的.

If you still get an error after doing this, then what worked for me eventually is that I deleted Json.Net's <dependentAssembly> section from my .config file. Reinstall brings it back if it's not there and apparently you need to delete it. Until there will be a normal solution in the package itself, I'm afraid this manual step is a must.

注意:请在执行此操作之前阅读下面的评论.

根据下面 René 的评论注意,答案中发布的命令将在您的解决方案中的每个项目中重新安装包.因此,如果您在多个项目中使用 Newtonsoft.Json 包并且可能使用不同的版本,那么仅执行上述命令可能会产生不良后果.

As per René's comment below BE AWARE that the command posted in the answer will reinstall the package in every project in your solution. So if you use the Newtonsoft.Json package in several projects and maybe use different versions, just executing the above command might have unwanted consequences.

这篇关于无法加载文件或程序集“Newtonsoft.Json,版本=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆