<$BlogRSDURL$>

Thursday, April 01, 2004

.Net: Playing with the GAC ....continued 

In order to faciliate my work I had to create a Custom Windows Control and since I was trying to use it in project which had a strong name, this particulat control also needed to be strong named. So, following are the steps to do strong-naming the assembly.

1. First thing one needs to do to create a strong name assembly is to generate strong name keys for the assembly. Microsoft Visual Studio ( not .Net Framework) ships with a Strong naming tool (sn.exe) which you can find at %Program Files&\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin. Usage of the tool is like

sn.exe -k .snk

snk=strong name key
Copy this file to the folder in the assembly which you need to strong name.

2. In the AssemblyInfo.cs file of the assembly you are trying to strong-name you will need to add the location of the keys like this
[assembly: AssemblyKeyFile(@"..\..\..\.snk")]

if the snk file lies in the folder above the source code folder and assembly file(dll) in the bin/debug.

3. In order to add the assembly to the GAC, use gacutil \i

Also read the previous post for pitfalls.

That is it, your asembly is strong-named and in the GAC!!

0 Comments:

Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?