How to share an assembly? How to make it strongly named? What is SN.EXE?
In order to share an assembly with many applications, it must have a strong name.
In order to convert a private assembly to a shared assembly, i.e. to create a strongly named assembly,
follow the steps below...
1) Create a strong key using the sn.exe tool. This is used to created a cryptographic key pair. The
key pair that is generated by the Strong Name tool can be kept in a file or we can store it our your local machine's Crytographic Service Provider (CSP). For this, goto the .NET command interpreter, and type the following...
sn -k C:\samplekey.snk
This will create a strong key and save it to the location C:\samplekey.snk
2) If the key is stored in a file, just like we have done above, we use the attribute AssemblyKeyFileAttribute.
This belongs to the namespace System.Reflection.AssemblyKeyFileAttribute.
If the key was in the CSP, we would make use of System.Reflection.AssemblyKeyNameAttribute.
Go to the assemblyinfo.vb file of your project. Open this file. Make the following changes in this file...
We may write this in our code as well, like this...
Public class Sample
CLI CTS Metadata CLS IL VES
Code Access Security
3) Build your project. Your assembly is now strongly named.
Installing the Shared assembly in GAC...
Go to .NET command interpreter, use the tool gacutil.exe
Type the following...
gacutil /i sampleclass.dll To uninstall it, use... gacutil /u sampleclass.dll Visual Studio.NET provides a
GUI tool for viewing all shared assemblies in the GAC.
Folder of GAC: C:\Windows\Assembly OR C:\Winnt\Assembly