如何使用bin文件夹程序集覆盖GAC程序集 [英] How to override GAC assembly with bin folder assembly

查看:89
本文介绍了如何使用bin文件夹程序集覆盖GAC程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI


在我目前的项目中,我们使用的是Microsoft.Practices.EnterpriseLibrary.Data.dll版本5.0.505.0,但在我的电脑中,GAC有5.0.414.0版本的相同版本DLL。在运行我的应用程序时它指的是GAC程序集。但是我需要参考我的bin文件夹中提供的更高版本的dll。我将copy复制到本地选项为true。



注意:卸载不是一个选项,因为我需要在我的GAC中保留旧版本。



到目前为止我在web.config中尝试了以下配置:

 <   runtime  >  
< assemblyBinding xmlns = urn:schemas-microsoft-com: asm.v1 >
< 探测 privatePath = < span class =code-keyword> bin / >
< dependentAssembly >
< codeBase version = 5.0.505.0 href = file:/// D:\ Testst\TestSQL\bin\Debug \ Microsoft.Practices.EnterpriseLibrary.Data.dll / >
< assemblyIdentity name = Microsoft.Practices.EnterpriseLibrary.Data

publicKeyToken = 31bf3856ad364e35

< span class =code-attribute> culture = 中性 / >
< 探测 privatepat = bin > < /探测 >
< bindingRedirect oldVersion = 5.0.414.0

< span class =code-attribute> newVersion = 5.0.505.0 / >
< / dependentAssembly >
< / assemblyBinding >
< /运行时 >





给出的结果

解决方案

通常,产品的两个不同版本可以在同一个GAC 并排中工作。在您的情况下,这非常简单:您只能使用GAC中安装的产品的一个版本。如果使用GAC程序集,当您添加引用时(使用Visual Studio,使用添加引用窗口的.NET选项卡),您实际上通过包含版本和公共名称的强名称引用该程序集关键令牌;对于不同的版本,两者应该是不同的。



您只需在GAC中安装第二版产品并使用其中一个或另一个。在最坏的情况下,您甚至可以临时取消注册GAC中的一个版本并在以后注册;您无需永久删除该版本。此外,您可以随时使用安装包。



请参阅: http://msdn.microsoft.com/en-us/library/ex0ss12c%28v=vs.110%29.aspx [ ^ ]。



另请参阅: http://msdn.microsoft.com/en-us/library/8477k21c%28v=vs.110%29.aspx [ ^ ]。



-SA

HI
In my current project we are using Microsoft.Practices.EnterpriseLibrary.Data.dll version 5.0.505.0, but in my computer GAC has 5.0.414.0 version of the same dll. while running my application it refers GAC assembly . But i need to refer higher version dll which is available in my bin folder .here i marked copy to local option as true.

Note : uninstalling is not an option since i need to keep older version in my GAC .

so far i tried the below configurations in my web.config:

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
           <probing privatePath="bin"/>
  <dependentAssembly>
    <codeBase version="5.0.505.0" href= "file:///D:\TestSQL\TestSQL\bin\Debug\Microsoft.Practices.EnterpriseLibrary.Data.dll"/>
    <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Data"

                      publicKeyToken="31bf3856ad364e35"

                      culture="neutral" />
    <probing privatepat="bin"></probing>
    <bindingRedirect oldVersion="5.0.414.0"

                     newVersion="5.0.505.0"/>
  </dependentAssembly>
</assemblyBinding>
</runtime>



its giving neagtive results

解决方案

Usually, two different versions of the product can work in the same GAC side-by-side. In your case, this is especially simple: you can use only one version of the product installed in GAC. In case of using a GAC assembly, when you add a reference (with Visual Studio, using the ".NET" tab of the "Add Reference" window), you actually reference that assembly by that strong name which includes the version and the public key token; both should be different for different version.

You can simply install the second version of the product in the GAC and use either one or another. In worst case, you can even temporary unregister one of the version from GAC and register it later; you won't need to permanently remove the version. Besides, you can always use the installation packages.

Please see: http://msdn.microsoft.com/en-us/library/ex0ss12c%28v=vs.110%29.aspx[^].

See also: http://msdn.microsoft.com/en-us/library/8477k21c%28v=vs.110%29.aspx[^].

—SA


这篇关于如何使用bin文件夹程序集覆盖GAC程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆