Giving a .NET Assembly a Strong Name (only strong type assembly can be added to GAC)


1. Create .netmodule file from source code
>csc /t:module welcome.cs // this command creates welcome.netmodule

2. Create strongnamekey.snk
> sn -k strongnamekey.snk // this cmd creates strongnamekey.snk

3. create strong-named assembly using assembly linker (al)
> al /out:welcome.dll welcome.netmodule /keyfile:strongnamekey.snk //this cmd create welcome.dll

4 Create welcome.exe using strong-named welcome.dll
> csc welcome.cs /r:welcome.dll

5. Install into GAC (C:/windows/assembly )
> gacutil -i welcome.dll // install welcome.dll into gac

> gacutil -u welcome.dll //remove it from gac

 

 

 

Delay Signing an Assembly ( More Info)

1. Create Public/Private keyfile.
> sn -k PublicPrivateKeyFile.snk

2. Extract public from PublicPrivateKeyFile.snk and place into publickeyFile.snk
> sn.exe -p PublicPrivateKeyFile.snk PublicKeyFile.snk

3. Associate assembly with public key , in AssemblyInfo.cs.

[assembly: AssemblyDelaySign(true)]
[assembly: AssemblyKeyFile("PublicFile.snk")]

4. instruct runtime skip digital signature verification
> sn.exe -Vr YourAssembly.dll

5. Unregister it for verification
> sn.exe -Vu YourAssembly.dll

6. performs the delay signing operation on the assembly
> sn.exe -R YourAssembly.dll PublicPrivateKeyFile.snk

7. Install assembly into GAC
> Gacutil -i assembly.dll

 

 

@Copy right of Soon Lim 2006. All Right Reserved