.NET - Module vs. Assembly

A .NET Assembly is a DLL or EXE in the CLR PE (Portable Executable) file format.

An assembly contains a manifest, and one or more modules.

The manifest describes the Assembly and its dependencies. Modules contain IL code and type information.

The Module

The module contains IL code and type Information (also called metadata).
Each module can be written in a different .NET language if needed.

Every type you create (class, struct, interface, enum, delegate), every field, property, method, method parameter, return value, and attribute, all adds type information to the module's metadata.

Single-module assemblies are the default. Visual Studio can create single-module assemblies only.
Multi-module assemblies are uncommon.

To create a multi-module assembly, you must use the command line.

 To create a single-module assembly
 csc.exe /target:exe      /out:Program.exe  Program.cs Class1.cs  --> Program.exe
 csc.exe /target:library  /out:Program.dll  Program.cs Class1.cs  --> Program.dll
 To create a multi-module assembly
 csc.exe /target:module   /out:Program.netmodule  Program.cs           --> Program.netmodule
 csc.exe /target:module   /out:Module1.netmodule  Class1.cs Class2.cs  --> Module1.netmodule
 al.exe  /target:exe      /out:Program.exe /main:mma.Program.Main  Program.netmodule Module1.netmodule  --> Program.exe
 csc = c-sharp compiler
 al  = assembly linker

The Manifest

The manifest contains metadata for the assembly. It includes:

  • The assembly version, publisher, culture, and strong name (if the assembly is signed).
  • A list of publicly exported types.
  • A list of modules in the assembly. Identified by module Name.
  • A list of referenced assemblies. Identified by Name, version, and public key token (if the referenced assembly is signed).

Ads by Google

Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath