无法加载文件或程序集"Newtonsoft.Json"或其依赖项之一 [英] Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies
问题描述
首先,它不仅仅是重复的.以下问题的答案都没有对我有用.
First, It is not just duplicate. None of answers from following questions are working for me.
http://goo.gl/tS40cn
http://goo.gl/pH6v2T
我刚刚使用Nuget软件包管理器更新了我的所有软件包,并且开始收到此错误.
I've just updated all my packages using Nuget Package Manager and I started receiving this error.
无法加载文件或程序集"Newtonsoft.Json,版本= 6.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed"或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配. (来自HRESULT的异常:0x80131040)
我的软件包配置有:
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
Web.config包含以下代码:
Web.config includes this piece of code:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
Newtonsoft.Json
根据类似问题的答案,我尝试了以下方法:
According to the answers from the similar questions, I have tried followings:
- 使用
Update-Package –reinstall Newtonsoft.Json
重新安装软件包
- 从
Web.config
中删除dependentAssembly
的Newtonsoft.Json
- 将
newVersion
更改为dependentAssembly
中的6.0.0.0
和7.0.0.0
.这样做产生了新的错误. - 也尝试了
Get-Project -All | Add-BindingRedirect
.它将Newtonsoft.Json
的newVersion
更改为4.5.0.0
.但是问题仍然没有解决.
- Reinstalling package using
Update-Package –reinstall Newtonsoft.Json
- Removing
dependentAssembly
config fromWeb.config
forNewtonsoft.Json
- Changing
newVersion
to6.0.0.0
and7.0.0.0
independentAssembly
. Doing so gave birth to new error. - Also tried
Get-Project -All | Add-BindingRedirect
. It changesnewVersion
forNewtonsoft.Json
to4.5.0.0
. But issue remains unresolved.
请帮助我解决此问题.
推荐答案
我知道这很旧,但是我遇到了同样的问题.我的问题是该解决方案中的多个项目都使用Newtonsoft.Json,但是其中一些版本不同.我将所有这些都更新为最新版本(在我输入时为9.0.1),问题消失了.
I know this is old, but I just ran into the same problem. My issue was that multiple projects in the solution used Newtonsoft.Json, but some were at different versions. I updated all of them to the most recent (9.0.1 as I type) and the problem went away.
无论如何...如果仍然有人在处理此问题,请确保在解决方案中的每个项目中更新软件包.
Anyway... if anyone is still dealing with this, make sure to update the package in EVERY project in the solution.
HTH
这篇关于无法加载文件或程序集"Newtonsoft.Json"或其依赖项之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!