Tuesday, January 11, 2011

Installing a dll in the global assembly cache - GAC


Where do we find the Global Assembly cache?
Your windows installation directory / Windows/Assembly  which can also be accessed through
%SystemRoot%/assembly
Steps to install an assembly into the GAC:

1. Strong Name the assembly by taking the project properties and taking the “Signing” Tab as in the image below.
image
Now check the “Sign the assembly” checkbox
In the “choose a strong name key file” select “<new>” where you fiind the following screen:

image
Enter a key file name, I entered the full project name. Untick the “Protect my key file with a password” checkbox and click ok.
You will find a snk file generated in the project.
image
2. With the assembly being strong named, we can now install this in the GAC. follow the following steps:
  • Build the project
  • Run the Visual Studio command prompt in “Run as administrator” mode by going to  Program files –> Microsoft Visual Studio 2010 –> Visual Studio Tools and right click the “Visual Studio Command Prompt” and select “Run as administrator”.
  • In the command prompt enter the following command
gacutil -I "D:\Temp\myproject.dll"



replace "D:\Temp\myproject.dll" with the fullly qualified dll name with path.

now go to %SystemRoot%/assembly , your project dll will have appeared in the GAC.

No comments:

Post a Comment