无法加载文件或程序集“Newtonsoft.Json,版本=4.5.0.0,文化=中性,PublicKeyToken=3

Could not load file or assembly #39;Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed#39;(无法加载文件或程序集“Newtonsoft.Json,版本=4.5.0.0,文化=中性,PublicKeyToken=30ad4fe6b2a6aeed) - IT屋-程序员软件开
本文介绍了无法加载文件或程序集“Newtonsoft.Json,版本=4.5.0.0,文化=中性,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é 在 BE AWARE 下面的评论,答案中发布的命令将在您的解决方案中的每个项目中重新安装包.因此,如果您在多个项目中使用 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,文化=中性,PublicKeyToken=30ad4fe6b2a6aeed"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
How delegates work (in the background)?(代表如何工作(在后台)?)
Func Delegate vs Function(函数委托与函数)
Checking a MethodInfo against a delegate(针对委托检查 MethodInfo)
How to get the instance of a referred instance from a lambda expression(如何从 lambda 表达式中获取引用实例的实例)
How to create a delegate to an instance method with a null target?(如何为具有空目标的实例方法创建委托?)