StrongKey in Assembly using C#
In this article we will discuss about how to make the strong key for Assembly in C#.
To build public and private keys we have to use the sn (short for strong name) utility. This utility generates a public/private key pair. The public key created using this utility will be used to define a strong name. To create the key pair we must type the following at command prompt:
The steps are as follows:
- Open the Visual Studio 2010.
- Then go to Visual Studio Tools.
- Then go to Visual Studio Command Prompt(2010).
- A Command prompt will open and write the following command to make the strong key file.
On executing the utility a file called mykey.snk gets created. The files contains the public and private keys. To create a strong name, the compiler uses the public key from mykey.snk file, hence we must provide this file to the compiler.
To see the location of the strong key file just go to the D: drive and mykey strong key file will be created. We can select the location as per our requirement.
Now we will assign the strong key to our assembly to make its name unique. The steps are as follows:
- Just go to location where you have make the dll.
- Then right click on the project folder and select the property option.
- Then choose the Signing option from the left hand sides option.
- Then check the checkbox of the sign the assembly.
- Then choose a strong key name from the dropdownlist just select the browse option from it and select the location of the strong key file.
In this way we will assign the strong key to our assembly then rebuild your dll to make changes. The strong key name make the assembly unique.
Ask Your Question
Got a programming related question? You may want to post your question here