需要澄清:在 GAC 中使用 .NET 程序集 - 设置为全局使用?

发布于 2024-09-03 17:13:17 字数 567 浏览 6 评论 0原文

今天,我已经就程序集的签名以及通过各种方法(mscorcfg.msc/拖放)将它们安装到 GAC 中进行了大量阅读和实验。

我的想法是,一旦文件位于 GAC 中,您就不需要从 Visual Studio 中的项目进行引用。我知道您可以通过通常的“添加参考”、“浏览”等方式进行参考,但我认为这是自动的。测试证明情况并非如此。

我遇到了一篇论坛帖子,希望获得相同的结果,建议添加到 system.web 下的 machine.config 文件,如下所示。

这不起作用,实际上它破坏了 Visual Studio,直到我将其删除。

   <assemblies>
                <add assembly="Blah.Framework.Logging, Version=1.0.3806.25580, Culture=neutral, PublicKeyToken=0beed4b631ebc3cd" />
            </assemblies>

我想知道的是,我在 GAC 中使用程序集的假设是否正确,是否有办法使它们在全球范围内可用?

I've done much reading and experimentation today regarding sigining of assemblies, and their installation into the GAC via various methods (mscorcfg.msc / drag and drop).

What I thought, was that once a file was in the GAC, you did not need to make references from projects in Visual studio. I know that you CAN make references via the usual Add Reference, Browse etc, but I thought it was automatic. Testing proves this not to be the case.

I came across a forum post looking to achieve the same outcome that suggested adding to the machine.config file under system.web as below.

This did not work, it in fact broke visual studio until I removed it.

   <assemblies>
                <add assembly="Blah.Framework.Logging, Version=1.0.3806.25580, Culture=neutral, PublicKeyToken=0beed4b631ebc3cd" />
            </assemblies>

What I want to know, is am I right in my assumed use of assemblies in the GAC, and is there a way of making them globally available?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天煞孤星 2024-09-10 17:13:17

全球可用并不意味着引用会自动添加到您的所有项目中。这意味着您不需要将 DLL 复制到应用程序的探测路径(Visual Studio 中的“复制本地”选项)。您仍然需要从 GAC 添加对项目的引用,但您选择的程序集不会复制到项目的 bin 文件夹(探测路径中的第一站)。

实际目的是不必重新分发 DLL )您随申请一起参考。您添加对它的引用,并且可以在将 DLL 添加到其 GAC 的任何计算机上找到该引用。

Globally available doesn't mean a reference is automatically added to all your projects. It means that you don't need to copy the DLL into the application's probing path (the "Copy Local" option in Visual Studio). You still need to add a reference to your project from the GAC, but the assembly you choose is not copied to the project's bin folder (the first stop in the probing path.)

The practical purpose is to not have to redistribute the DLL(s) you reference along with your application. You add a reference to it, and that reference will be found on any machine that has the DLL added to it's GAC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文