"George" <Ge****@discussions.microsoft.comwrote in message
news:4C**********************************@microsof t.com...
I am very interested in this method,
--------------------
add a Strong Name and
install the dll into the Global Assembly Cache.
--------------------
But I have never done this before, could you let me know how to configure
in
more details?
First you need to generate a Key File. You open a Visual Studio Command
Prompt (start->Visual studio->tools) and you enter this command:
sn -k MyKeys.snk
This wil generate the file "MyKeys.snk". You only have to do this once.
Then you store MyKeys.snk in a safe place and you can use it to sign all
your programs.
Next: In the project of the dll that you want to sign with a Strong Name,
find the file AssemblyInfo.cs, open it, and you will find an attribute
called AssemblyKeyFile. There you add the path of your .snk file:
[assembly: AssemblyKeyFile(@"path\MyKeys.snk")]
You should also modify the AssemblyVersion and enter a "fixed" version
number such as "1.0.0.0" instead of the existing "auto-increment" version
number that contains an asterisk.
That's it. You now compile your dll and it will receive a Strong Name. If
you get a "cryptographic error" while compiling, that means that you wrote a
wrong path to the snk file.
Now that the assembly has a Strong Name, you can install it to the GAC.
One way to do this is to execute the command "gacutil -i mylibrary.dll".
Another way is to open c:\Windows\Assembly in Windows Explorer, and then
drag and drop your DLL to that location.
Once you have done this, any .net executable that wants to load your dll
will be able to find it, regardles of the location of the .exe in the
filesystem.