我得到了错误

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>

它也没有起作用


当前回答

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

对我来说是这样的:)

其他回答

右键单击您的项目选择管理Nuget包,在搜索框中输入newtonsoft并安装最新版本。然后运行你的应用

下面的部分添加到您的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>

看看Newtonsoft的版本。Json Newtonsoft属性

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

我在7.0.0.0版本中遇到了完全相同的问题,导致我的问题的库是Microsoft.Rest.ClientRuntime,它以某种方式引用了错误的Newtonsoft版本(6.0.0.0)。Json,尽管正确的依赖管理在nugget(正确版本的newtonsoft。Json(7.0.0.0)被安装)。

我通过在配置文件中应用上述从6.0.0.0重定向到7.0.0.0(从Kadir Can)来解决这个问题:

<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="7.0.0.0" />

---->经过几天没有改变任何东西,它又出现了同样的错误。我安装了6.0.0.0版本,更新到7.0.0.0,现在可以正常工作了。

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

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

这将解决你的问题。

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