An assembly is the basic building block in .NET. It is the compiled
format of a class, that contains Metadata, Manisfest & Intermediate Language
An assembly may be either Public or Private. A public
assembly means the same as Shared Assembly.
Assembly - This type of assembly is used by a single application. It is
stored in the application's directory or the applications sub-directory. There
is no version constraint in a private assembly.
Shared Assembly or
Public Assembly - A shared assembly has version constraint. It is stored in
the Global Assembly Cache (GAC). GAC is a repository of shared assemblies
maintained by the .NET runtime. It is located at C:\Windows\Assembly OR
C:\Winnt\Assembly. The shared assemblies may be used by many applications.
To make an assembly a shared assembly, it has to be strongly named. In
order to share an assembly with many applications, it must have a strong name.
A Strong Name assembly is an assembly that has its own identity,
through its version and uniqueness.
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 http://www.dotnetuncle.com/difference/47_public_private_assembly.aspx# using the sn.exe tool. This is used to
created a cryptographic key pair. http://www.dotnetuncle.com/difference/47_public_private_assembly.aspx# 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 http://www.dotnetuncle.com/difference/47_public_private_assembly.aspx#.Reflection.AssemblyKeyFileAttribute. If
the key was in the CSP, we would make use of
Go to the assemblyinfo.vb
file of your http://www.dotnetuncle.com/difference/47_public_private_assembly.aspx#. Open this file. Make the following
changes in this file...
We may write this in
our code as well, like this...
Public class Sample
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...
To uninstall it, use... gacutil /u
sampleclass.dll. Visual Studio.NET provides a GUI tool for viewing all shared
assemblies in the GAC.