About GAC

J

julien

Hello,
I read several articles about the GAC. Here is my understanding

The GAC has 2 main purposes:
a/ avoid having the same shared dll loaded several times by different
programs
b/ several versions of a dll can run in parallel. It is also easy to
update the version of a dll in a GAC without rebuilding the applications
that depend on it

For security reasons, DLLs loaded in the GAC must have a strong name so
that a trusted DLL cannot be replaced by a malicious library.


I still have a couple of questions about the GAC:

1/ I've seen a couple of articles that make a difference between private
libraries (not to be loaded in the GAC) and shared libraries (to be
loaded in the GAC). My (stupid!) question would be: instead of
separating private libraries from shared libraries, if we know that a
private library will run all the time, can I just load it in the GAC
(and so having a single DLL with shared objects and private objects)?

2/Let's say I have the library Shared.dll signed by the vendor MyCompany
used by a couple of applications. Later, I find out that the vendor
OtherCompany has a 100% compatible library with Shared.dll, but with
less bugs, called OtherShared.dll. So, I would like to swap these 2
libraries without rebuilding all the applications depending on it
(especially if I don't have their source code). Is it possible to do
this? How?

Thank you
Julien
 
C

Carlos J. Quintero [.NET MVP]

julien said:
1/ I've seen a couple of articles that make a difference between private
libraries (not to be loaded in the GAC) and shared libraries (to be loaded
in the GAC). My (stupid!) question would be: instead of separating private
libraries from shared libraries, if we know that a private library will
run all the time, can I just load it in the GAC (and so having a single
DLL with shared objects and private objects)?

Sometimes you have libraries that are only used by one app, because they are
very specific to that exe. In that case, you deploy it privately in the same
folder (o subfolder) of the exe. You only deploy in the GAC if you want to
offer it to other apps.
2/Let's say I have the library Shared.dll signed by the vendor MyCompany
used by a couple of applications. Later, I find out that the vendor
OtherCompany has a 100% compatible library with Shared.dll, but with less
bugs, called OtherShared.dll. So, I would like to swap these 2 libraries
without rebuilding all the applications depending on it (especially if I
don't have their source code). Is it possible to do this? How?

It is not possible without changing references and recompiling, since shared
(GAC) libraries must be strong named, and the strong name is composed of
name, version, culture and public key token. You can only swap libraries if
they differ on minor version differences (and maybe culture, not sure) and
the myapp.exe.config file instructs the run-time to do it so.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 
S

Serge Baltic

C> Sometimes you have libraries that are only used by one app, because
C> they are very specific to that exe. In that case, you deploy it
C> privately in the same folder (o subfolder) of the exe. You only
C> deploy in the GAC if you want to offer it to other apps.

Suppose I want to put one of the libraries in the GAC. It gets updated from
time to time. How should I write the manifest for my exe if I want it to
work with any version of the DLL? Say, if EXE is in between 1.0 and 1.5,
and in GAC there's some DLL of version 1.0 up to 1.5, that's OK and can be
referenced. By default, the strong name involves binding to the particular
version, which is not nice due to multiple reasons.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Is the GAC dynamic? 2
ClickOnce and GAC 1
using GAC 4
Assembly.LoadXXX methods and GAC 3
About private and shared assembly 1
shared assemblies 2
Global Assembly Cache 7
When to use the GAC? 3

Top