无法加载文件或程序集"Newtonsoft.Json"或其依赖项之一

编程入门 行业动态 更新时间:2024-10-28 08:30:42
本文介绍了无法加载文件或程序集"Newtonsoft.Json"或其依赖项之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

First, It is not just duplicate. None of answers from following questions are working for me.

goo.gl/tS40cn 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 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"或其依赖项之一

本文发布于:2023-11-03 06:18:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554429.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:或其   加载   文件   程序   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!