我得到了错误

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>

它也没有起作用


当前回答

上面没有任何帮助,但真正解决问题的是以下几点:

删除app.config中的所有依赖项绑定(从解决方案中的所有app.config文件中) 从“包管理器控制台”执行以下命令

Add-BindingRedirect

重建

参考: http://blog.myget.org/post/2014/11/27/Could-not-load-file-or-assembly-NuGet-Assembly-Redirects.aspx

其他回答

通常情况下,添加绑定重定向应该可以解决这个问题,但对我来说行不通。经过几个小时的思考,我意识到在我的web.config中有一个xmlns属性导致了问题。从Web中的配置节点中删除xmlns属性后。配置时,绑定重定向按预期工作。

http://www.davepaquette.com/archive/2014/10/02/could-not-load-file-or-assembly-newtonsoft-json-version4-5-0-0.aspx

下面的部分添加到您的web.config

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <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>
    </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

这对我很管用。

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

为我工作....只需将你正在使用的版本放在newVersion中,即(newVersion="7.0.0.0")

你应该更新网页。配置文件在服务器。 当nuget安装NewtonSoft更新这个文件,包括这个代码

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <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>
</assemblyBinding>