Monday, February 05, 2007 6:01 AM
Chris
Creating Strongly Named Assemblies
When deploying a .Net project to production, it is often necessary to install an assembly into the Global Assembly Cache(GAC). The GAC is where you want to install assemblies that you want to share on your computer.
Creating a Strong Name
Before we begin, you must understand that there is a requirement that you strongly name all assemblies that are being installed in the GAC. In order to do so, you must create a strong name key, using the Strong Name tool "sn.exe", as follows:
sn –k NeudesicTest.snk
Note that the strong name key consists of a public/private key pair. For security reasons you will want the private key protected. There are options in the strong name tool that will permit you to split the public and private keys so that you could "delay sign" your assemblies. In addition, your company will typically have one strong name key. Don't make the mistake of creating a strong name key per project, unless of course you are a consultant and each project is for a different company. In this case, it is likely that the company will already have their own key.
Adding the Strong Name Key to the Solution
Now that we have a strong name key, let's add the strong name key to our project.
Note that since the solution that I'm using has three projects, will want to add the strong name key to each project. This is where I will show you an advanced option.
- Add an existing item to each of the projects
- Navigate to the location of the strong name key and select it.
- Here is where things will differ a bit. Instead of double clicking the strong name key, or selecting add, notice that the Add button has a small arrow on the right side. Select the arrow and then select "As Link".

This option will add the strong name key file as a link to the project but will not copy the file into the project folder. This is a cool way of sharing a single file, regardless of type, across several projects.
- The Solution Explorer now shows that the strong name key is linked into all of the projects in our solution.
We can now strongly name our assemblies.
Strongly Naming Assemblies
- Select Project Properties
- From the tabs on the left select "Signing"
- Select the check box "Sign the assembly"
- When you select the drop down you will now see the strong name key that we linked into our projects.
- Select the strong name key
- Repeat these steps for each project that will be strongly named.
Note that, for security reasons, any assemblies that are referenced by the assemblies that are being strongly named, must also be strongly named.
Next time we will examine deploying strongly named assemblies to the GAC.