gpt4 book ai didi

c# - System.Net.Http.Formatting.dll 导致 Newtonsoft.Json 出现问题

转载 作者:可可西里 更新时间:2023-11-01 08:48:15 25 4
gpt4 key购买 nike

我的 Windows 服务与 MVC 项目位于同一解决方案中。

MVC 项目使用对需要 Newtonsoft.Json v6 + 的 SignalR Client 的引用

Windows 服务使用 System.Net.Http.Formatting,这需要 Newtonsoft.Json 版本 4.5.0.0。

我原以为这不会是个问题,因为我可以在我的 App.Config 中使用绑定(bind)重定向,但是我得到了一个错误

An unhandled exception of type 'System.IO.FileLoadException' occurred in System.Net.Http.Formatting.dll

Additional information: 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)

我的 app.config 具有以下内容:

<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>

我自己添加的,它不起作用,我也尝试使用 nuget 包管理器卸载并重新安装 Json.Net,但无济于事

最佳答案

我们遇到了同样的错误,并努力修复了几天。我们终于在堆栈溢出上找到了这篇文章 Assembly reference cannot be resolved - dependentAssembly issue?

这让我们意识到要查看正在使用的 System.Net.Http.Formatting 版本,我们发现我们的解决方案一直在使用多个版本的 System.Net.Http。 Formatting.dll 和它们中的每一个都引用了不同版本的 Newtonsoft.Json.dll

删除旧版本的 System.Net.Http.Formatting 的引用并重新添加引用,解决了这个问题。

希望对您有所帮助。

关于c# - System.Net.Http.Formatting.dll 导致 Newtonsoft.Json 出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30976835/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com