无法加载文件或程序集"Newtonsoft.Json"或其依赖项之一 [英] Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies

查看:878
本文介绍了无法加载文件或程序集"Newtonsoft.Json"或其依赖项之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,它不仅仅是重复的.以下问题的答案都没有对我有用.

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中删除dependentAssemblyNewtonsoft.Json
  • newVersion更改为dependentAssembly中的6.0.0.07.0.0.0.这样做产生了新的错误.
  • 也尝试了Get-Project -All | Add-BindingRedirect.它将Newtonsoft.JsonnewVersion更改为4.5.0.0.但是问题仍然没有解决.
  • Reinstalling package using Update-Package –reinstall Newtonsoft.Json
  • Removing dependentAssembly config from Web.config for Newtonsoft.Json
  • Changing newVersion to 6.0.0.0 and 7.0.0.0 in dependentAssembly. Doing so gave birth to new error.
  • Also tried Get-Project -All | Add-BindingRedirect. It changes newVersion for Newtonsoft.Json to 4.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屋!

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