Monday, June 17, 2013

What is a Global Assembly Cache (GAC)

The Global Assembly Cache (GAC) is a common folder where the shared assemblies are placed. The GAC folder is placed in one of the following folders.

X:/Windows/assembly
(or)
X:/Winnt/assembly

Where X: is the driver where the .Net framework in installed, it might vary from machine to machine based on where the .Net Framework is installed.

For an Assembly to be placed in the GAC, it should be signed with a strong name key, generated using the sn.exe utility. Once the assembly is signed with the key and is ready for deployment, it can be deployed in the GAC in one of the following ways.
1. Using an Installer application which placed the Assembly in the GAC. This approach is suitable when packing an application with its dependent assembly files. The end user does not need to know much about GAC, the installer package can automatically install the assembly.

2. Using the built in .Net utility “gacutil”. This involves running the command in the Command prompt and specifying the assembly to be installed in the command line as follows.

         gacutil /i myassembly.dll

3. By simply dragging/copying the assembly into the GAC folder. This can be done only by users who have access to the GAC directory, generally only Admin users have access to this path, and hence this approach is not suitable for all users.

The following screen shows the structure of the GAC.
As you can see from the screen image, the GAC contains the following details about an assembly. Assembly Name Version Culture Public Key These details are placed in the AssemblyInfo file before building the assembly, when the assembly is installed in the GAC these details are reflected in the GAC.

Search Flipkart Products:
Flipkart.com

No comments: