GAC Assembly

GAC Assembly


In this post we will see how to add assembly into GAC or Global assembly cache.

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

e.g.

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 file xxx.snk and paste it into your class library project.

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

E.g.
Open assemblyinfo

add below line

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


Save your assemblyinfo.cs file.

Compile the project.

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.

To know path of assembly you can find it under Debug or release folder of your BIN folder.


Now, your all applications can refer this shared assembly.

You can browse your GAC using technique shown here: http://www.revenmerchantservices.com/ajax/systemwebextensions.html

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5