How to put Assembly In GAC

How to put Assembly In GAC

In this, post we will see how to put assembly into GAC or Global assembly cache. Here we will also see how to use
GACUTIL and .net command prompts

To add assembly into GAC we need sign the assembly with strong name.

You can get the Key pair by opening .Net command prompt and execute SN -k c:\xxxxx.snk


Setting environment for using Microsoft Visual Studio 2005 x64 cross tools.

c:\Program Files\Microsoft Visual Studio 8\VC>sn -k c:\xxx.snk

Microsoft (R) .NET Framework Strong Name Utility  Version 2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

Key pair written to c:\xxx.snk

c:\Program Files\Microsoft Visual Studio 8\VC>

Now, copy the file xxx.snk generated by tool and paste it into your class library project.

open the assemblyinfo file give the path of newly created strongname keypair as shown in below example.
Compile the project. Now, your assembly is ready to get into GAC.

Open assemblyinfo

add below line

[assembly: AssemblyKeyFile("xxx.snk")]

Save your assemblyinfo.cs file.

Compile the project.

Now, we will register assembly in gac.

Open your .Net command prompt

Use GACUtil -i to install the assembly into gac

c:\Program Files\Microsoft Visual Studio 8\VC>gacutil -i path_Of_your_signed_assembly.

You can find the assembly under Debug or Release folder of your BIN folder.

Now, your all applications can refer this shared assembly.

You can also browse GAC location using technique shown here:
GAC AssemblyGac Assembly LocationASP.NET resources in separate assemblycould not load file or assemblyCould not load file or assembly SystemServiceModelDomainServicesHosting Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35 or one of its dependencies The system cannot find the file specified[C#] Remove Last Character From StringAndroid install APK from computer applicationUpside Down computer screenJQuery Form With ValidationThe floating point value is out of the range of computer representation (8 bytes) Convert String To Image


My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.

I'm Satalaj.