Introduction To Assemblies   


An assembly is self-describing because it includes metadata that describes the assembly. Metadata includes the types exported from the assembly and a manifest. A Manifest is a data structure. The manifest serves the same purpose as the type library and associated registry entries do for a COM component. Manifest contains more information than a type library.

Assemblies can be loaded using the side-by-side technique. This means a different version of the same assembly can be used inside a single process.

Assemblies support Zero-impact installations. Installations can be as easy as copying the files that belong to an assembly.


Structure of an Assembly

As told before the assembly consists of assembly metadata describing the assembly, type metadata describing the exported types and methods, MSIL code, and resources.

These parts of an assembly can be inside one file or spread across several files.


Manifests

The manifest is an important part of an assembly and is part of the metadata. A manifest contains:

  1. The identity of the assembly, consisting of its name, version and culture.

  2. Names of all the files in the assembly.

  3. Details of all the types defined in the assembly.

  4. Whether all the types defined in the assembly are visible to other assemblies or private to one.

  5. A hash of all files in the assembly

  6. Names and hashes of other assemblies that an assembly in turn will need to reference when run

  7. Details of any security permissions that clients need to have in order to be able to run the assembly


Shared & Private Assemblies

There are two types of assemblies available: private assemblies and shared assemblies. A private assembly is used by only one application while a shared assembly is shared among different applications.

By default when we compile a C# program, the assembly produced will be a private assembly. The file should be placed in the same folder where the calling application is stored. With a private assembly it’s not necessary to think about naming conflicts with other classes or versioning problems because each application has its own copy of the assembly.

In shared assemblies we must be careful that the assembly must be unique, and therefore, have a unique name (called a strong name).