zoukankan      html  css  js  c++  java
  • 无法加载文件或程序集“Newtonsoft.Json”或它的某一个依赖项

    未能加载文件或程序集“Newtonsoft.Json”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)。

    有时候我们创建了一个类库,我们项目又引用了这个类库,需要我们把Newtonsoft.Json统一化。

    对每个引用Newtonsoft.Json的项目做下面的处理:

    ①删除bin下面的Newtonsoft.Json.dll

    ②重新nuget引用Newtonsoft.Json到一个版本(看实际情况,一般是最新)

    ③添加我们的依赖,然后重新生成

     version="1.0" encoding="utf-8"?>
    <configuration>
      <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="4.5.0.0" />   <!-- newVersion 一般都是你在nuget种引用的版本的  -->  
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>

    特殊情况:

    如果你这样做了还是报错,列如:

    "未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)"

    执行上面的步骤,把Newtonsoft.Json引用到报错的版本

  • 相关阅读:
    洛谷P1056_排座椅 贪心+桶排思想
    NOIP普及组相关
    洛谷P1464_Function 记忆化搜索
    Xcode的使用技巧
    MAC_XCODE清理
    输入框跟随键盘移动效果的实现
    #pragma的进阶用法
    iOS 逆向
    警告框
    UIImageView设置圆角的方式
  • 原文地址:https://www.cnblogs.com/Sea1ee/p/10575356.html
Copyright © 2011-2022 走看看