TechShri from Shriniwas Wani

Custom Search

17 January, 2006

Strong Naming Concept..

Whenever you want to put the assembly (. dll) file to GAC , it asks for strong name.
I used this when working with sharepoint


When you're building assemblies, it's not hard to apply a strong name to them.

1) Create a strong name assembly key fileFrom a VS.NET command prompt, use the SN.EXE utility to create a file containing the public key/private key pair:
c:\>sn -k c:\strongNameKeyPair.snk


2) Add reference to the assembly key file to your assembly projectOpen the AssemblyInfo.cs file in your project and add the following attribute:
[assembly: AssemblyKeyFile(@"c:\strongNameKeyPair.snk")]

3) Compile your assembly
same way you would any other day of the week.

4) Obtain the public key to your key fileYou may need this in the future. After you build your assembly, from a VS.NET command prompt, use the SN.EXE
utility again to get the public key of your key pair:
c:\>sn -T assemblyName.dll

(Added 12/16) Obtain the public key blob to your key fileYou'll need this in CAS policy files... it's the hex public key blob...
use the SECUTIL.EXE
utility:c:\>secutil -hex -s yourAssembly.dll