zoukankan      html  css  js  c++  java
  • 程序集冲突问题

    今天遇到一个奇怪的问题,我的A类库引用了Newtonsoft.Json.dll (8.0.0.0),主程序应用了A类库,发现程序运行时报错,提示无法加载Newtonsoft.Json.dll,后来发现Newtonsoft.Json.dll未输出到主程序Bin目录,重新连接类库编译都不能解决问题,仔细发现编译有个Warning 提示,如下:

    No way to resolve conflict between "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
    8> Consider app.config remapping of assembly "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" from Version "8.0.0.0" [D:workXXXXXXXinDebugNewtonsoft.Json.dll] to Version "9.0.0.0" [] to solve conflict and get rid of warning.

    奇怪的是我没有程序集或类库引用了9.0的版本,怀疑之前是使用Nuget管理,自动升级到8.03版本,后来引用本地引用8.0的版本,也不知道具体原因,网上找方案,最终如下方法解决:

    在主程序的App.config中加入如下

    <?xml version="1.0"?>
    <configuration>
    <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
    </startup>
    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="9.0.0.0" newVersion="8.0.0.0" />
    </dependentAssembly>
    </assemblyBinding>
    </runtime>
    </configuration>

    重新编译解决。

    相关信息查看

    publicKeyToken可以通过Develper command prompt for vs2012工具查看,

    sn -T dll路径

  • 相关阅读:
    win10自带邮箱应用无法查看qq邮箱应用解决办法
    Ubuntu紫色背景颜色代码
    VMware中对Linux虚拟机的网络配置静态IP的配置
    CentOS 7在VMware 12中共享文件看不见的问题?
    C++中让人忽视的左值和右值
    C++ allocator类学习理解
    C++11新特性 -----> 右值引用 &&
    重新认识new
    关于C++中nothrow的某某某
    stopPropagation, preventDefault 和 return false 的区别
  • 原文地址:https://www.cnblogs.com/karl-F/p/6482771.html
Copyright © 2011-2022 走看看