Assemblies in C# : Part 1

 

Assembly

  • An Assembly is a basic unit of application deployment and versioning.
  • An Assembly is also called the building block of a .Net application.
  • An Assembly is either a .exe or .dll file. 

An Assembly structure consists of the following parts:

  • Assembly manifest (name,language,version).
  • CIL code (logic part).
  • Type information (Datatype).
  • Resources.

  1. An Assembly manifest consists of the information of an assembly.
  2. Represents the .Net program as per Microsoft standards.
  3. It consists of the information of all the types used in the assembly.
  4. It consists of images that are part of the assembly, but not included in the CIL/MSIL code. 

Assembly Versioning

Assembly Versioning is a new feature introduced in .Net that allows two versions of the same component that exists in a single machine and in a single folder side-by-side.

A version number is assigned by the programmer and is not provided or controlled by .Net software.

Types of Assemblies

There are the following 2 types of Assemblies:

  1. Private Assembly (.exe)
  2. Shared Assembly (.dll) (in other words a class library)

Private Assembly

A Private Assembly is an assembly that can be used in a single application (project).

Shared Assembly

A Shared Assembly is an assembly that can be used in multiple applications.

Strong-Named Assembly

A Strong-Named Assembly is a shared named assembly along with a public key and version number.

Public key

A Public key is also called a strong named key. It is a 1024 bit hexadecimal code that provides security of the assembly.

A Strong-Named assembly ensures that an assembly cannot be tampered with.

Global Assembly Cache (GAC)

A strong-named assembly consists of a unique version number that can only exist more than once with the same name.

The GAC is a machine-wide independent location that allows Strong-Named assemblies to register.

It is a location where 2 versions of the same component can exist.

GAC Location

See the following to understand how to view the GAC Location.

Note: .NET 4.0 Framework and above (Window 8).

 
Figure 1:
GAC Location

 
Figure 2:  Assembly Name and Versions

Thank you.


Similar Articles