zoukankan      html  css  js  c++  java
  • 同一个解决方案或有依赖关系的两个项目引用同名但不同版本的DLL

    问题描述

          我们最近在使用Redis作Session的集中化,中间碰到了一个如下问题:我们有一些项目比较老,引用了NewtonJson的4.0.3.0版本的DLL,但是Redis提供的C#集成DLL引用的是NewtonJson的7.0.0.0版本的DLL,但我们要在老项目中引用Redis集成DLL,因而就碰到了NewtonJson的版本冲突问题。

      

    解决方案一

          我们可以通过配置web.config(或者app.config)来帮助我们解决这个问题。需要在web.config中配置如下节点:  

    1 <runtime>
    2     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    3       <dependentAssembly>
    4         <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
    5         <codeBase version="4.0.3.0" href="C:v2.0Newtonsoft.Json.dll" />
    6         <codeBase version="7.0.0.0" href="C:v3.5Newtonsoft.Json.dll" />
    7       </dependentAssembly>
    8     </assemblyBinding>
    9   </runtime>

        说明1:有的朋友博客上面说,需要在主项目中引用最新版本的DLL,经过实验是不需要这样做的。

        说明2:name填程序集的名称,pulicKeyToken是数字签名,version是程序集的版本,href指不同版本的程序集的地址,我尝试过,无法使用相对路径,必须使用绝对路径,可能使用相对路径也可以,但需要另外的配置,如果有朋友知道,麻烦分享一下。 

    解决方案二

      如果在同一个项目中引用不同版本的DLL,但新版本的DLL兼容旧版本的DLL,那么可以采用如下的配置:

    1 <runtime>
    2     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    3       <dependentAssembly>
    4         <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    5         <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
    6       </dependentAssembly>
    7     </assemblyBinding>
    8   </runtime>

    参考文档

       http://www.cnblogs.com/EugeneMay/p/4249709.html

      http://bbs.csdn.net/topics/390359027

  • 相关阅读:
    GhostNet: More Features from Cheap Operations
    Distribution-Aware Coordinate Representation for Human Pose Estimation
    如何从零开始学习自动化
    selenium---博客园登录
    selenium---屏幕截图
    selenium---web页面定位toast
    selenium---JS修改属性处理日历控件
    selenium---cookie处理
    selenium---处理SSL证书错误问题
    selenium---JS处理滚动条
  • 原文地址:https://www.cnblogs.com/gudi/p/6958297.html
Copyright © 2011-2022 走看看