June 2008
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Search

 
Catagories
Archives
Recent Entries
Links
RSS
installing an assembly into the GAC
Catagory: programming · This Entry · Comment(0) · eMail entry · Google
March 22, 2004 01:01 PM

programming

Global Assembly Cache : to generate a strong name, and to install a .dll file of the project in the GAC, follow these steps . . .


In Visual Studio .NET, create a new Visual C# .NET Class Library project, and name the project GACDemo.

You must use a strong name. To generate this cryptographic key-pair, use the SN Tool. This tool is located in the \bin subdirectory where the .NET Framework Solution Developer Kit (SDK) is installed. The SN Tool is easy to use. The command-line statement takes the following
form:sn -k "[DriveLetter]:\[DirectoryToPlaceKey]\[KeyName].snk"

Create a directory named GACKey in C:\ so that you can easily locate the key, and access the key from the command prompt.

Note For most users, the .NET tools are located in C:\Program Files\Microsoft.NET\FrameworkSDK\Bin. Before you type the following SN command, you may want to copy this similar path on your computer to the .NET bin directory. Type cd from the command prompt, right-click to paste the path, and then press ENTER to quickly change to the directory where the SN Tool is located.

Type the following:
sn -k "C:\GACKey\GACkey.snk"

A key is generated, but it is not yet associated with the assembly of the project. To create this association, double-click the AssemblyInfo.cs file in Visual Studio .NET Solution Explorer. This file has the list of assembly attributes that are included by default when a project is created in Visual Studio .NET. Modify the AssemblyKeyFile assembly attribute in the code as follows:
[assembly: AssemblyKeyFile("C:\\GACKey\\GACKey.snk")]

Compile the project by clicking CTRL+SHIFT+B. You do not have to have any additional code to install a .dll file in the GAC.
You can install the .dll file by using the Gacutil Tool, or by dragging the .dll file to the appropriate directory. If you use the Gacutil Tool, you can use the following command:
gacutil -I "[DriveLetter]:\[PathToBinDirectoryInVSProject]\gac.dll"

If you want to drag the file, use Microsoft Windows Explorer. Open two instances of Windows Explorer. In one instance, find the location of the .dll file output for your console project. In the other instance, find c:\[SystemRoot]\Assembly.

Drag your .dll file to the Assembly folder.


http://support.microsoft.com/default.aspx?scid=kb;en-us;815808

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconinstallingassemblyintoglobalassemblycache.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconglobalassemblycache.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfglobalassemblycacheutilitygacutilexe.asp





Comments

Post a comment
Name:


Email Address:


URL:


Comments: