If an assembly is to be accessed by multiple applications, the assembly must be placed into a
well-known directory, and the CLR must know to look in this directory automatically when a
reference to the assembly is detected. This well-known location is called the global assembly
cache (GAC), which can usually be found in the following directory (assuming that Windows
is installed in the C:\Windows directory):
C:\Windows\Assembly
The GAC directory is structured: It contains many subdirectories, and an algorithm is used to
generate the names of these subdirectories. You should never manually copy assembly files
into the GAC; instead, you should use tools to accomplish this task. These tools know the
GAC's internal structure and how to generate the proper subdirectory names.
While developing and testing, the most common tool for installing a strongly named assembly
into the GAC is GACUtil.exe. Running this tool without any command-line arguments yields
the following usage:
.....................................................................................................................................................................
The Global Assembly Cache (GAC) is a machine wide cache of strongly named .Net assemblies and acts as a central repository for shared libraries.
The GAC is installed on every machine with the .Net framework and contains a reference to all the strongly named assemblies that have been installed on the machine. The GAC stores assemblies intended to be shared by several applications on the computer and as such you should only install libraries into the GAC when you need to. As a general guideline, keep assembly dependencies private, and locate assemblies in the application directory unless sharing an assembly is explicitly required.
Assemblies installed into the GAC must be strongly named. When an assembly is added to the global assembly cache, integrity checks are performed on all files that make up the assembly. These checks ensure that an assembly has not been tampered with, but do not ensure that the publisher is who they say they are.
well-known directory, and the CLR must know to look in this directory automatically when a
reference to the assembly is detected. This well-known location is called the global assembly
cache (GAC), which can usually be found in the following directory (assuming that Windows
is installed in the C:\Windows directory):
C:\Windows\Assembly
The GAC directory is structured: It contains many subdirectories, and an algorithm is used to
generate the names of these subdirectories. You should never manually copy assembly files
into the GAC; instead, you should use tools to accomplish this task. These tools know the
GAC's internal structure and how to generate the proper subdirectory names.
While developing and testing, the most common tool for installing a strongly named assembly
into the GAC is GACUtil.exe. Running this tool without any command-line arguments yields
the following usage:
.....................................................................................................................................................................
The Global Assembly Cache (GAC) is a machine wide cache of strongly named .Net assemblies and acts as a central repository for shared libraries.
The GAC is installed on every machine with the .Net framework and contains a reference to all the strongly named assemblies that have been installed on the machine. The GAC stores assemblies intended to be shared by several applications on the computer and as such you should only install libraries into the GAC when you need to. As a general guideline, keep assembly dependencies private, and locate assemblies in the application directory unless sharing an assembly is explicitly required.
Assemblies installed into the GAC must be strongly named. When an assembly is added to the global assembly cache, integrity checks are performed on all files that make up the assembly. These checks ensure that an assembly has not been tampered with, but do not ensure that the publisher is who they say they are.
Why Use the Global Assembly Cache?
There are several advantages to using the GAC for shared assemblies. These include:- Shared Location: Assemblies that are used my many applications can reference the GAC, instead of a separate version being distributed with each application.
- File Security: Administrators often protect the WINNT directory using an Access Control List (ACL) to control write and execute access. Because the global assembly cache is installed in the WINNT directory, it inherits that directory's ACL. It is recommended that only users with Administrator privileges be allowed to delete files from the global assembly cache.
- Versioning: Because the assemblies are strongly named, they have a unique reference which allows multiple versions to be installed on the same machine. This allows for older applications to reference the old assembly, while newer applications to use a later version.
Installing to the GAC
There are two methods for installing an assembly into the global assembly cache; using the Windows Installer deployment tool, or manually using the gacutil.exe tool. Gacutil.exe should not be used to unless the assembly is to be installed on a development machine. The recommended method is to use the Windows Installer as it provides reference counting of assemblies in the global assembly cache, plus other benefits.Using Windows Installer
To install an assembly using the Windows Installer, create a new installer project and click on the menu View »t; File System. On the left hand side, right click and select "add global assembly cache folder", click on the GAC then in the right hand side click add. Browse to the assembly to be installed and compile the project.To use gacutil
To install an assembly into the GAC use the following command:gacutil.exe -I <assembly name>
To remove an assembly use:
gacutil.exe -U <assembly name>
0 comments:
Post a Comment