bin 和 gac 中的 Dll,使用哪个? [英] Dll in both the bin and the gac, which one gets used?

查看:36
本文介绍了bin 和 gac 中的 Dll,使用哪个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 Web 应用程序,该应用程序部署到许多网站,仅更改前端,共享后端部分在 GAC 中有它的 DLL,因此我们只需更新那个 DLL,所有站点都会得到更新.

We have a web application that's deployed to many websites with only frontend changes, the shared backend portion has it's DLL in the GAC so we only have to update that one dll and all the sites get the update.

有没有办法用/bin 文件夹中的 DLL 覆盖 GAC,以便在新功能发布之前对其进行测试?

Is there a way to override the GAC with a DLL in the /bin folder to test out new features before they get released?

推荐答案

如果它与引用的 DLL 具有相同的版本号,则使用 GAC.

If it has the same version number as the referenced DLL, the GAC gets used.

如果你增加版本号,参考新版本号重建网站,把新版本放到/bin目录下,那么那个DLL就会被使用.

If you increment the version number, rebuild the website referencing the new version number, put the new version in the /bin directory, then that DLL will be used.

如果您不想更改版本号,那您就很不走运了.

If you do not want to change the version number, you're pretty much out of luck.

当 .NET 加载强命名程序集时,它首先会尝试决定要使用的版本号.它首先通过引用执行此操作,然后查找发布商政策,然后它在配置文件中查找 binding redirects.

When .NET loads strong named assemblies, first it tries to decide what version number to use. It does this via the reference first, then it looks for publisher policies, then it looks for binding redirects in the configuration file.

执行此操作后,它会在 GAC 中查找程序集,然后在任何 指定代码库,然后它会探测 DLL 的各种文件系统文件夹.如果在其中任何一个步骤中找到正确的版本程序集,它就会停止.

After it does this, it looks for the assembly in the GAC, then in any codebase specified, then it probes various file system folders for the DLL. If at any one of those steps it finds the right version assembly, it stops.

如果您不更改强命名程序集的版本号,.NET 将在 GAC 中找到原始版本并停止查找.请注意,因为它会在找到时停止,并且首先在 GAC 中查找,因此除非您还指定新版本号,否则为程序集指定代码库不会有任何好处.

If you are not changing the version number of your strong named assembly, .NET will find the original one in the GAC and stop looking. Note that because it stops when it finds one, and because looking in the GAC is first, specifying a codebase for your assembly will do no good unless you also specify a new version number.

这篇关于bin 和 gac 中的 Dll,使用哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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