Monday, June 17, 2013

Signing an Assembly

Signing an Assembly requires generating a key file and mapping it to a Shared assembly. There are 2 types of assemblies, private and shared assemblies. Private assemblies are private to the application and are placed in the same folder as the application files. Shared assemblies are those which are shared across multiple applications in the same machine.

Before we could sign an Assembly we need to generate a key file which will be used for signing. To sign the assembly we can use the .Net Utility sn.exe

sn.exe -k MyPublicPrivateKeyFile.snk

The key file contains a combination of private and public keys which will later be used by the publisher and the consumer to the assembly to establish a secured relationship.

Once the assembly key file is generated, it can be linked to the assembly in 2 ways.
1. Using the Assembly linker tool Al.exe as follows.
      al /out:MyAssembly.dll MyModule.netmodule /keyfile:MyPublicPrivateKeyFile.snk

2. By specifying the path of the newly created key file in the AssemblyInfo file

Once the assembly is signed it can be placed in the Global Assembly Cache (GAC) and can be used by all the applications in the system.

Search Flipkart Products:

No comments: