Assembly in .NET 2.0


Before the .NET platform was introduced, we had to deal with the predecessors of assemblies: normal DLLs exporting global functions and COM DLLs exporting COM classes. Microsoft itself introduced the phrase DLL Hell to describe traditional problems with DLLs.


The answer to DLL Hell

The .NET platform answer to DLL Hell and to all of its problems is Assemblies.
Assemblies are self describing installation units, consisting of one or more files.

Features of assemblies

(1) Assemblies are self-describing.

(2) Version dependencies are recorded inside an assembly manifest.

(3) Assemblies can be loaded side-by-side.

(4) Application isolation is endured using application domains.

(5) Installation can be as easy as copying the files that belong to an assembly.
(6) Assemblies can be private or shared.

Assembly Structure 


 Assembly Metadata

   Type Metadata

        IL Code


In this example, the assembly metadata, type metadata, MSIL code, and resources all in one file- Component.dll. The assembly consists of a single file.

Assembly Manifests

An important part of an assembly is a manifest, which is part of the metadata. It describes the assembly with all the information that needed to reference it and lists all its dependencies.

Private and Shared Assemblies

A private assembly is found either in the same directory as the application, or within one of its subdirectories. With the private assembly it is not necessary to think about naming conflicts with other classes or versioning problems. Private assemblies are the normal way to build assemblies, especially when applications and components are built within the same company.

While using shared assemblies, we have to aware of some rules. The assembly must be unique and therefore must also have a unique name called a strong name. Shared assemblies will mostly used when a vendor, different from that of the application, builds the component.

Creating modules and assemblies

Creating a module by using the command line c# compiler csc.

The command  

csc /target:module hello.cs

creates a module hello.netmodule. we can view this module using ildasm.

We can compare modules to assemblies  by creating a simple class A and compile it by using the following command:

csc /target:module A.cs

Command to build an assembly B that includes the module A.netmodule.

csc /target:library/addmodule:A.netmodule /out:B.dll

Create a Strong name

A strong name is needed to share this assembly. We can create such a name with the strong name tool (sn):

Sn -k file.snk

The strong name utility generates and writes a public/private key pair, and writes this pair to a file; here the file is file.snk.

How to manage assemblies in windows

When we install .NET on our computer, some additional tools are installed in Windows to help us manage .NET and assemblies. We can find these tools navigating from the Start button. Go to:

Control Panel > Performance and Maintenance > Administrative Tools > Microsoft .NET 2.0 Configuration

The tool helpfully checks to see if we have given the component a strong name before allowing the copy.