How to generate key to strong name assembly using SN

by Viper 22. January 2009 17:18

A lot of times when you working on some redistributable commercial libraries or applications, you like to strong name your assembly. The key to generating strong name assembly is signing your assembly with a strong name key. It is very easy to generate this key. I will outline simple steps to generate your key quickly.

  • From Start > Visual Studio {Version} > Visual Studio Tools menu goto "Visual Studio {Version} Command Prompt" menu item. See the screen shot below.
    Doing it this will make sure that all the required binaries are in the PATH for command prompt.
  • Type SN - k {FileName}.snk to generate strong name key file that will need to sign the assemblies.
  • Now copy this generate file to appropriate location in your project and you can add a line of code in your code to sign the assembly. Following snippet shows the code that I added to my project in Assembly.cs file.
    
    [assembly: AssemblyDelaySign(false)]
    [assembly: AssemblyKeyFile("..\\..\\..\\MySNFile.snk")]
    [assembly: AssemblyKeyName("")]
    
    
Give your advice to big bosses and make money

Views: 708

Tags:

.Net

Comments

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.5.1.7
Theme by Naveen Kohli

By Categories