全局程序集缓存的目的是什么? [英] What is the purpose of Global Assembly Cache?

查看:97
本文介绍了全局程序集缓存的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道GAC的一般目的是在许多应用程序中共享一个组件。但即使您向GAC添加了某些内容,您仍然需要在项目中手动创建对DLL的引用(对吗?)。那么我通过将其添加到GAC获得了什么?

I know the general purpose for the GAC is to share a component among many applications. But even when you add something to the GAC, you still have to manually create a reference to the DLL in your project (right?). So what have I gained by adding it to the GAC?

推荐答案

如果您要引用非共享程序集(来自应用程序的私人

程序集),您最终会将该

程序集的副本放在应用程序的bin文件夹中。当您对共享程序集进行

引用时,您没有得到副本,您正在使用

一个注册到GAC的程序集。

" Simon Wallis" <硅********* @ discussions.microsoft.com>在消息中写道

新闻:F8 ********************************** @ microsof t.com ...
If you were to make a reference to a non-shared assembly (a private
assembly) from an application, you would wind up with a copy of that
assembly being placed in your application''s bin folder. When you make a
reference to a shared assembly, you don''t get a copy, you are working of the
one assembly registered into the GAC.
"Simon Wallis" <Si*********@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
我知道GAC的一般目的是在许多
申请中共享一个组件。但即使你向GAC添加了一些东西,你仍然需要手动创建项目中DLL的引用(对吗?)。那么通过将它添加到GAC我获得了什么?
I know the general purpose for the GAC is to share a component among many applications. But even when you add something to the GAC, you still have to
manually create a reference to the DLL in your project (right?). So what
have I gained by adding it to the GAC?



>如果您要从应用程序引用非共享程序集(私有
> If you were to make a reference to a non-shared assembly (a private
程序集),您最终会得到一份放在应用程序中的
程序集的bin文件夹。当您对共享程序集进行
引用时,您没有得到副本,您正在使用注册到GAC的一个程序集。
assembly) from an application, you would wind up with a copy of that
assembly being placed in your application''s bin folder. When you make a
reference to a shared assembly, you don''t get a copy, you are working of the
one assembly registered into the GAC.



这确实回答了我的问题,谢谢。但是,如果副本是由一个程序集组成的,为什么会这样呢?必须有一个更大的理由,因为在bin文件夹中放置一堆dll副本只是相当混乱。也许这很明显,但我是新手。您能否给我一个场景,说明为什么不使用GAC会不好?


另一个问题:我已经在几个地方读到微软建议不要使用GAC,除非你真的需要在多个应用程序之间共享程序集。使用GAC会导致他们提出这样的建议有什么大不了的?它只是一种最佳实践吗?仅用于共享程序集,或者如果GAC被过度使用会遇到某些问题?



That does answer my question, thanks. But why is it bad if a copy is made of an assembly? There must be a greater reason than it''s just rather messy to have a bunch of copies of a dll lying around in bin folders. Perhaps it is obvious but I''m new to this. Can you give me a scenario that shows why not using the GAC would be bad?

Another question: I''ve read in several places that Microsoft recommends against using the GAC unless you really need to share an assembly across several apps. What is the big deal in using the GAC that would cause them to make such a recommendation? Is it just a "best practice" to use it only for sharing assemblies, or can one run into certain problems if the GAC is over-used?




Simon Wallis <硅********* @ discussions.microsoft.com>在消息中写道

新闻:2B ********************************** @ microsof t.com ...

"Simon Wallis" <Si*********@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com...
如果你要从应用程序引用非共享程序集(私有程序集),你会最后将该
程序集的副本放在应用程序的bin文件夹中。当您对共享程序集进行引用时,您没有得到副本,您正在使用
注册到GAC的一个程序集。
这确实回答了我的问题,谢谢。但是,如果制作副本
If you were to make a reference to a non-shared assembly (a private
assembly) from an application, you would wind up with a copy of that
assembly being placed in your application''s bin folder. When you make a
reference to a shared assembly, you don''t get a copy, you are working of the one assembly registered into the GAC.
That does answer my question, thanks. But why is it bad if a copy is made



,为什么会这么糟糕呢?必须有一个更大的理由,因为在bin文件夹中放置一堆dll的副本只是相当混乱

。也许它很明显,但我是新手。你能给我一个场景,说明为什么没有使用GAC的
会不好吗?


没有人说它是坏的使用私人(非共享)程序集,但是如果你执行了更改并且对原始程序进行了更改,那么您的应用程序将无法知道这些更改的原因是什么?你会在副本上工作。

另一个问题:我已经在几个地方读过微软推荐


of an assembly? There must be a greater reason than it''s just rather messy
to have a bunch of copies of a dll lying around in bin folders. Perhaps it
is obvious but I''m new to this. Can you give me a scenario that shows why
not using the GAC would be bad?

No one said it was "bad" to use a private (non-shared) assembly, but if you
do and changes get made to the original, your application wouldn''t know
about those changes because you would be working from a copy.

Another question: I''ve read in several places that Microsoft recommends



反对使用GAC,除非你真的需要在几个应用程序之间共享一个程序集。使用GAC会导致他们提出这样的建议有什么大不了的?它只是一种最佳实践吗?仅将它用于

共享程序集,或者如果GAC过量使用会导致某些问题?


嗯,GAC *仅*用于共享程序集,没有其他用途

。所以,如果你不需要共享程序集,为什么要通过麻烦

(安装程序集需要一些设置和注册工作

到GAC这样做?你的应用程序必须有额外的开销

在它共享时添加(不是很大,但有些),如果你不需要
需要共享程序集,没有理由这样做。



against using the GAC unless you really need to share an assembly across
several apps. What is the big deal in using the GAC that would cause them to
make such a recommendation? Is it just a "best practice" to use it only for
sharing assemblies, or can one run into certain problems if the GAC is
over-used?

Well, the GAC is *only* used for sharing assemblies, there is no other use
for it. So, if you don''t need a shared assembly, why go through the bother
(there is some setup and registration work needed to install an assembly
into the GAC) of doing so? Your application has to have additional overhead
added to it when it is shared (not a huge amount, but some) and if you don''t
need a shared assembly, there''s no reason to do it.



这篇关于全局程序集缓存的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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