Skip to main content

A short description about .Net Assembly

What is an assembly?
An assembly is a collection of one or more .exe or dll’s. An assembly is the fundamental unit for application development and deployment in the .NET Framework.
An assembly contains a collection of types and resources that are built to work together and form a logical unit of functionality.

What are the contents of assembly?
A static assembly can consist of four elements:
1. Assembly manifest - An assembly manifest contains the information about the identity and version of the assembly. It also contains the information required to resolve references to types and resources.
2. Type metadata - Binary information that describes a program.
3. Microsoft intermediate language (MSIL) code.
4. A set of resources.

What are the different types of assembly?
1. Private assembly: A private assembly is installed in the installation directory of an application and is accessible to that application only.
2. Shared assembly: Shared assembly is shared by multiple applications. A shared assembly has a strong name and is installed in the GAC.
3. Satellite assembly: Satellite assemblies are often used to deploy language-specific resources for an application.

What is a dynamic assembly?
A dynamic assembly is created dynamically at run time when an application requires the types within these assemblies.

What is a strong name?
You need to assign a strong name to an assembly to place it in the GAC and make it globally accessible. A strong name consists of a name that consists of an assembly's identity (text name, version number, and culture information), a public key and a digital signature generated over the assembly.
The .NET Framework provides a tool called the Strong Name Tool (Sn.exe), which allows verification and key pair and signature generation.

What is GAC? What are the steps to create an assembly and add it to the GAC?
The global assembly cache (GAC) is a machine-wide code cache that stores assemblies specifically designated to be shared by several applications on the computer. You should share assemblies by installing them into the global assembly cache only when you need to.
Create a strong name using sn.exe tool eg: sn -k mykey.snk
In AssemblyInfo.cs, add the strong name eg: [assembly: AssemblyKeyFile("mykey.snk")]
recompile project, and then install it to GAC in two ways :
Drag & drop it to assembly folder (C:\WINDOWS\assembly OR C:\WINNT\assembly) (shfusion.dll tool)
gacutil -i abc.dll