我得到了错误

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>

它也没有起作用


当前回答

关闭解决方案。

打开包。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

这对我很管用。

其他回答

uninstall-package newtonsoft.json -force
install-package newtonsoft.json

对我来说是这样的:)

看看Newtonsoft的版本。Json Newtonsoft属性

然后你需要在你的web配置中添加这个版本(在我的例子中是8.0.0.0) 网络配置

我得到了同样的错误,并通过添加以下代码错误解决了生产。

回答这个问题已经太迟了,但也许能帮到别人。

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>

关闭解决方案。

打开包。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

这对我很管用。

我修复了添加这个绑定重定向到我的.config文件的问题:

<runtime>
    . . . 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"
                culture="neutral" />
            <bindingRedirect oldVersion="4.5.0.0" newVersion="6.0.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

错误消息抱怨找不到版本4.5.0.0,当前版本的Newtonsoft。Json是6.0.0.0,所以重定向应该从4.5到6.0,而不是相反