Vous êtes sur la page 1sur 3

Add an Assembly to the GAC

Hello! This is a short article describing how to add an assembly to the GAC.

Here are the steps:

1. Open the command prompt with administrator privileges.

2. Navigate to the folder where the sn.exe and the gacutil.exe are located.

On the Command Prompt, execute this instruction:

cd C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0


Tools\x64

This is usually the most commonly place where the mentioned tools are located, but it
can be located on another place (on a server for example). Just make sure that the
gacutil.exe and the sn.exe are located on the folder path that you specified on the
command.

3. Create a strong name for the DLL (if you have a strong name already for the
DLL, skip this step).

On the Command Prompt, execute this instruction:

sn -k Folder_Path_Where_The_DLL_Is_Located\DLL_Name.snk

This will create you the .snk (strong name key) file on the location where you have
the DLL.
4. Reference the strong name on the AssemblyInfo.cs file on the project where you
created the DLL.

Here is the code:

...
[assembly: AssemblyKeyFile(@"Strong_Name_Path")]
...

5. Add the DLL to the GAC.

If you closed the Command Prompt window, redo step 1 and 2, and then execute this
command:

gacutil /i DLL_PATH
And that is all. If you have any questions or comments, please post it bellow or send
me an email to the address specified on the About section. God Bless!

Vous aimerez peut-être aussi