.net - 与 Newtonsoft.Json 的装配冲突

标签 .net json.net .net-assembly

我需要加载 2 个版本的程序集 Newtonsoft.Json 版本 4.0.8.0 和 4.5.0.0。我当前的配置文件:

<dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.8.0" />
</dependentAssembly>

但它必须是:旧的 4.0.8.0 和新的 4.5.0.0
  <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.5.0.0" />
      </dependentAssembly>

我从 Package Console 安装了 Newtonsoft - 最新版本 - 但它给了我一个错误:

Error 80 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)**

最佳答案

我今天遇到了这个问题,我在这个 link 中找到了解决方案.

基本上更新 Newtonsoft.Json 包。并在 web.config 中注册这个程序集

<dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="5.0.8"/>
</dependentAssembly>

关于.net - 与 Newtonsoft.Json 的装配冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19225776/

相关文章:

.net - Visual Studio - 未启用所有调试控件

.NET 预分配内存与临时分配

c# - 通过 JSON.Net 分解 JSON 中的对象列表

c# - 如何使用 Newtonsoft.Json 将对象序列化为带有类型信息的 json?

c# - 从其他项目打开 wpf 窗口

c# - 在读/写 Access 数据库时获得最少锁定时间的最佳方法

c# - 行为不当的 Screen.AllScreens.Length

json - 如何获取Newtonsoft.Json反序列化值的未转义字符串值?

.net - 在 PS 类中引用程序集会导致 "Unable to find type"错误

c# - 调用 Assembly.Load(byte[]) 可以引发 AppDomain.AssemblyResolve 事件吗?