Types of Assemblies

Programs and libraries for .NET are packaged into units called assemblies. An assembly can be defined as versioned, self-describing binary dynamic link library(DLL) or executable(EXE) containing a collection of types.

An assembly is self-descriptive and consists of three elements:

  • Manifest - Contains metadata information such as name, version, culture, referenced assemblies, and security requirements.
  • Microsoft Intermediate Language (MSIL) Code - Gets generated when you compile an application by using the .NET compiler.
  • Resources - Include the resource files for the application.

Types of Assemblies

Assemblies are broadly categorized on the basis of:

  • Grouping of elements
  • Accessibility

Grouping of Elements

There are several ways to group the various elements in the assembly. You can group all the elements in a single physical file or group them separately in several files. Based on the grouping of elements, assemblies are further divided into two types, single file and multifile assemblies.

Single-File Assemblies

An assembly that groups all the elements in a single file is called a single-file assembily. This assembly can be created by compiling the application in Microsoft Visual Studio .NET.

Multifile Addemblies

An assembly that groups its elements in multiple files is called a multifile assembly. These assemblies can be created using the command-line compiles.

Accessibility

Based on their accessibility assemblies are further divided into two types, private and shared assemblies.

Private Assemblies

Private assemblies are accessible only to the application residing in the same directory as that of the assembly. When you create an assembly, it is private by default.

Shared Assemblies

Shared assemblies are added to the Global Assembly Cache (GAC). GAC is reserved for storing assemblies and for sharing them between multiple applications. In as shared system, the names of the assemblies should be unique because the assemblies can be accessed by multiple applications. Therefore, you need to assign a strong name to assemblies before adding to the GAC.