Wisdom of Helios

GAC in .net 4.0

Leave a comment

What is GAC ?

GAC stands for “Global Assembly Cache”. GAC is a machine – based code cache(memory are of .Net) that stores assemblies to be shared by different .net applications on a given computer (where CLR exists). Even two assemblies with the same name but different versions or cultures may coexist in the GAC.

Ways to deploy Assemblies into GAC

To access the assemblies we have to install our desired assemblies to GAC. There are two ways to deploy Assemblies into the GAC.

Using Windows Installer

Use an installer designed to work with the global assembly cache (i.e. Windows Installer 2.0). This process is widely used in Deployment purpose. It is preferred and recommended process because Windows Installer provides refference counting assemblies in GAC and other facilities.

Manually using Developer Tool

We can use the gacutil.exe to deploy assemblies into GAC. This process is widely used in Development purpose.

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>

So, Where is the  GAC ?

The .NET Framework includes an Assembly Cache Viewer. Open Windows Explorer, enter %windir%\assembly in the address bar, and all global assemblies will appear in a special view that shows the assembly name, version, culture, public key token, and processor architecture.

               

What Problem is solved by GAC ?

DLL Hell problem is solved in .NET with the introduction of Assembly versioning. It allows the application to specify not only the library it needs to run, but also the version of the assembly.

An Important consideration regarding  GAC ?

Assemblies deployed in the global assembly cache must have a strong name. When an assembly is added to the global assembly cache, integrity checks are performed on all files that make up the assembly. The cache performs these integrity checks to ensure that an assembly has not been tampered with, for example, when a file has changed but the manifest does not reflect the change.


Author: Munir

I'm good for nothing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s