Search code examples
c#.netencryptionsn.exe

How to import an .snk file generated with sn.exe in .NET?


I have created a key file with this command:


 sn.exe -k 2048 Build.snk

I would like to read in this key with .NET. I haven't been able to find any document as to the format of the .snk, so I'm wondering if there's a way in C# to read in an .snk file?

My original reason for asking the question was to use the .snk file for purposes other than signing an assembly. As one of the answers states below, the purpose of .snk files is really just for signing assemblies.


Solution

  • Strong naming keys are used at compile-time to sign the assemblies produced by the compiler--so reading them in during runtime probably isn't what you want.

    To get started look for the "Signing" tab in your C# Project's Properties window--there you can choose what .snk to sign the assembly with.

    http://msdn.microsoft.com/en-us/library/xc31ft41(VS.100).aspx