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

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

问题描述

我收到错误

System.IO.FileLoadException:无法加载文件或程序
  Newtonsoft.Json,版本= 4.5.0.0,文化=中立,
  公钥= 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>

这也没有工作。

推荐答案

在包管理器控制台执行:更新封装-reinstall Newtonsoft.Json

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

更新

我最初发布这个作为一个评论,但作为@OwenBlacker建议我只把它放在这里:

如果你仍然这样做后得到一个错误,那么什么工作对我来说,最终是我删除Json.Net的&LT; dependentAssembly&GT; 部分从我的的.config 文件。重新安装带回来,如果它不存在,显然你需要将其删除。直到将在包本身正常的解决方案,这恐怕手动步骤是必须的。

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.

注意:请在此之前阅读下面的意见

按如下勒的评论注意这张贴在回答该命令将重新安装包解决方案中的每一个项目。所以,如果你在几个项目中使用的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,文化=中性公钥= 30ad4fe6b2a6aeed”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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