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

  • 相关阅读:
    $python日期和时间的处理
    $python生成器
    $思维导图——numpy基本知识
    $python用装饰器实现一个计时器
    $ MySQL-python数据库模块用法
    CentOS 7.2下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1
    Nginx、Apache工作原理及Nginx为何比Apache高效
    Apache的三种工作模式及相关配置
    ThinkPHP框架
    session与cookie的区别是什么?如果客户端禁用了cookie功能,将会对session有什么影响?
  • 原文地址:https://www.cnblogs.com/karl-F/p/6482771.html
Copyright © 2011-2022 走看看