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

Tags:

GAC AssemblyGac Assembly LocationASP.NET resources in separate assemblycould not load file or assemblyCould not load file or assembly SystemServiceModelDomainServicesHosting Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 or one of its dependencies The system cannot find the file specifiedMembership ProviderAsp.net Interview Questions for 2 years or 3 years experianceDateTime in C# current Date and TimeAsp.net Convert String To ImageC# HtmlTextWriter Example

Author

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 ASP.net 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.