20

What is Managed Module in .NET and how is it different from Assemblies? Is a PE file (eg. test.dll) a managed module or an assembly? How does assembly/managed module correspond to physical files on disk?

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249

3 Answers3

17

A Managed module is generally understood to refer to a module that only contains IL code, with no direct machine code.

A module is housed in a normal PE file.

An assembly is a set of 1 or more modules, with one designated as the 'head' (will look up the exact term[1]). A module on its own isnt individually much use though - the assembly is the atomic unit.

For example, you could have an multui-module assembly with 2 DLLs and an EXE. Multi module assemblies are quite rare though.

The Don Box book Esssential .NET, the Richter CLR via C# gives good coverage of the topic. For complete details, the Serge Lidin .NET 2.0 IL Assembler book and the CLI standard are more complete.

[1] According to http://www.programmersheaven.com/2/FAQ-DOTNET-DOTNET-Assembly-Explained

An assembly can be a single file or it may consist of the multiple files. In case of multi-file, there is one master module containing the manifest while other assemblies exist as non-manifest modules

To answer the actual questions:-

What is Managed Module in .NET and how is it different from Assemblies?

It is a subset - a DLL can be a master module with no child modules -- and thus be an assembly too

Is a PE file (eg. test.dll) a managed module or an assembly?

Definitely a module. If it also has a manifest and no child modules, it's also an assembly

How does assembly/managed module correspond to physical files on disk? Each module is a file. (Tools like ILMerge can merge modules if you're interested)

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
0

A module contains IL and many of them are linked together to create an assembly, which is usually housed in a PE like a .exe or a .dll.

A PE can contain native (non managed) code as well.

This is a good intro to the concepts.

Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
0

Managed modules are the compiled IL versions of the source code. The extension of the file that is built when making a module from source files is .netmodule.

Assemblies are either DLLs or .exe files containing managed modules, resources, and metadata.

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
rahul
  • 184,426
  • 49
  • 232
  • 263