Placing a .NET assembly in the GAC using MMC and sn.exe
Step 1: Locate the assembly
• See the screenshot below
• Switch to the directory location of assembly that you want to place in GAC.
• Verify whether the assembly is strongly named or not, by typing the following command:
sn –v myassembly.dll (-v switch verifies whether that assembly represents a strongly named assembly or not.)
• If it represents a strongly named assembly, skip to step 4.
Step 3: So you have an assembly that needs to be strongly named?
• Create a key pair file that can be assigned to an assembly. To create a new key pair file
Use sn –k keyfile.snk. Place this key file (keyfile.snk) in to the root of the application
(where AssemblyInfo.cs resides). See screenshot below.

• Now we’ll have to assign this keyfile.snk to an assembly to make it strongly named.
• Open the Project in Visual Studio.NET
• Open the “AssemblyInfo.cs” file.
• Find the key named [assembly: AssemblyKeyFile(“”)]
• Change this to [assembly: AssemblyKeyFile(“keyfile.snk”)]
• Compile the Project. The generated assembly will have a strong name.
Note: Don’t forget to include key file in project compilation.
Step 4: Using MMC
• Open MMC from Start Menu > Run (see below)

• In MMC, Open mscorcfg.msc file. This file can by default be located
at C:\WINDOWS\Microsoft.NET\Framework\
• The screen below illustrates the MMC snap-in for mscorcfg.msc.

• Choose “Assembly Cache” Node.
• Click on “Add an Assembly to the Assembly Cache”.
• Select the desired assembly.
• That’s it!
• To check whether this worked for you or not, click on “View List of Assemblies in the Assembly Cache” in the same pane.
• Check the assembly’s version and Culture information against your specification in AssemblyInfo.cs.
- Locate the correct version of assembly with the mode you want to work with. (Debug, Release)
• See the screenshot below
• Switch to the directory location of assembly that you want to place in GAC.
• Verify whether the assembly is strongly named or not, by typing the following command:
sn –v myassembly.dll (-v switch verifies whether that assembly represents a strongly named assembly or not.)
• If it represents a strongly named assembly, skip to step 4.
Step 3: So you have an assembly that needs to be strongly named?
• Create a key pair file that can be assigned to an assembly. To create a new key pair file
Use sn –k keyfile.snk. Place this key file (keyfile.snk) in to the root of the application
(where AssemblyInfo.cs resides). See screenshot below.
• Now we’ll have to assign this keyfile.snk to an assembly to make it strongly named.
• Open the Project in Visual Studio.NET
• Open the “AssemblyInfo.cs” file.
• Find the key named [assembly: AssemblyKeyFile(“”)]
• Change this to [assembly: AssemblyKeyFile(“keyfile.snk”)]
• Compile the Project. The generated assembly will have a strong name.
Note: Don’t forget to include key file in project compilation.
Step 4: Using MMC
• Open MMC from Start Menu > Run (see below)
• In MMC, Open mscorcfg.msc file. This file can by default be located
at C:\WINDOWS\Microsoft.NET\Framework\
• The screen below illustrates the MMC snap-in for mscorcfg.msc.
• Choose “Assembly Cache” Node.
• Click on “Add an Assembly to the Assembly Cache”.
• Select the desired assembly.
• That’s it!
• To check whether this worked for you or not, click on “View List of Assemblies in the Assembly Cache” in the same pane.
• Check the assembly’s version and Culture information against your specification in AssemblyInfo.cs.
Comments