What is GAC & How to handle multiple versions in GAC?

GAC-Global Assembly Cache is where all shared .NET assembly reside.

GAC is used in the following situations-

1. If the assembly has to be shared among several application which are in the same computer.

2. If the assembly has some special security, requirements like only administrator can remove the assembly. If the assembly is private for program then a simple delete of assembly can delete the assembly file.


Our all share assembly is located in “c:\WINDOWS\assembly\” where we can also see the version and public key token of assembly.


To register any assembly in GAC we have to follow bellow steps-

1. Assign strong name to Assembly

2. Copy the Assembly in another location (like d:\Commondll\) and then register the dll in GAC by 2 ways. First way-

I. Go to Visual studio command prompt

II. Go to d:\Commondll\ (where our Assembly is copied)

III. Just type- gacutil -i common.dll

Second way-

Just drag and drop common.dll file from source to “c:\WINDOWS\assembly\”


Note- We can cross check by search the common.dll in “c:\WINDOWS\assembly\”


Now to use common.dll registered in GAC we have to add reference in windows application from “d:\Commondll\common.dll” and then use common namespace in windows application and now we can use all methods of common.dll in our windows application.

After compilation we will move the windowapplication.exe to “d:\Commondll\” and we can see the .exe running properly because it’s linked with common.dll register in GAC and reside in the same folder.

To create a new version of .dll file in GAC go to Properties->AssemblyInfo.cs in Common class library and update the assembly version- [assembly: Assemblyversion(“”)] and then after build the application lets register this assembly in GAC.

To change the pointing dll by any application-

1. Go to Administrative Tools->Microsoft .NET Framework 2.0 Configuration

2. Right click on Applications in the left hand side tree structure and add windowapplication

3. Select windowapplication after it will add to Applications and click on “Managed Configured Assemblies” then “Configure an Assembly”-> “Choose an assembly from the assembly cache”-> click on “Choose Assembly” and then choose Common which has version and click on Finish.

4. As we click on finish we will get new popup which has Binding Policy tab and enter in Requested Version and in New Version. It creates windowapplication.exe.config file which will redirect the control to new version when it calls for old version.


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