我得到了错误

fileloadexception:无法加载文件或程序集 “Newtonsoft。Json,版本=4.5.0.0,文化=中性, PublicKeyToken=30ad4fe6b2a6aeed'或其依赖项之一。的 定位程序集的清单定义与该程序集不匹配 参考。(异常来自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>

它也没有起作用


当前回答

我犯了一个错误,为。net 4.5添加了一个NewtonSoft .dll文件。

我的主要项目是4.5,但当我向我的解决方案添加一个额外的项目时,它奇怪地将它添加为。net 2.0项目……当我试图使用NewtonSoft的4.5 dll时,我得到了这个“NewtonSoft”。Json cannot 't be found”错误。

解决方案(当然)是将这个新项目从。net 2.0改为4.5。

其他回答

移除牛顿软。Json程序集从项目引用并再次添加它。您可能不小心删除或替换了dll。

对我来说,问题是一个贬值版的Newtonsoft.Json。重新安装也无济于事。

在Visual Studio中,进入工具->管理NuGet包。选择更新。搜索Newtonsoft。单击Update安装最新版本。

关闭解决方案。

打开包。Config和*。用csproj文本编辑器删除任意一行都有Newtonsoft。Json

Ex:

<Reference Include="Newtonsoft.Json,Version=9.0.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
      <HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
      <Private>True</Private>
</Reference>

Or

<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />

再次打开解决方案并重新安装Newtonsoft。Json由安装包Newtonsoft。Json

这对我很管用。

我花了几天时间试图解决这个令人沮丧的问题。我几乎试遍了网上能找到的所有方法。最后我发现这个错误可能是由一个解决方案中不同的目标. net项目版本(4.5和4.5.1)引起的(就像我的情况一样)。下面的步骤帮我解决了这个问题:

仔细检查解决方案中每个项目的. net版本。只需右键单击项目,然后进入属性。

If possible set the same .Net version for all projects. If not at least try to change the Startup project one (for me this was the one causing the issues). Remove all Newtonsoft.Json packs from the solution. uninstall-package newtonsoft.json -force Update all Newtonsoft.Json versions in all packages.config files, like so <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net451" /> Reinstall Newtonsoft.Json from "Package Manager Console" with: install-package newtonsoft.json Rebuild the solution

(可选)7。如果更改了Startup项目,请再次返回

你有两个不同版本的JSON。NET库。要解决这个问题,你应该把它们升级到最新版本。遵循以下步骤:

1-打开解决方案资源管理器 2右键单击解决方案名称 3选择“解决方案管理Nuget包” 从菜单中选择“更新” 5 update JSON。净包

这将解决你的问题。

链接: 无法加载文件或程序集'Newtonsoft。Json,版本=7.0.0.0,文化=中性,PublicKeyToken=30ad4fe6b2a6aeed'或其依赖项之一