What is a module in .NET?


Question

What exactly is a module? What is the difference between a module, a class and a function? How can I access a module in C#?

I am asking this because I want to calculate a checksum of the IL code of only some particular functions, at runtime (without using code signing).

1
51
10/6/2018 3:22:05 PM

Accepted Answer

A module is a logical collection of code within an Assembly. You can have multiple modules inside an Assembly, and each module can be written in different .NET languages (VS, as far as I'm aware, doesn't support creation of multi-module assemblies).

Assemblies contain modules. Modules contain classes. Classes contain functions.

Yes you can access assemblies, modules, classes, functions, properties, fields etc all via reflection at runtime.

52
5/23/2013 4:09:57 AM

As an addition to the other answers:

The MSDN states that: "A module is a Microsoft intermediate language (MSIL) file that does not have an assembly manifest.".

Modules can be "linked" together by generating an assembly manifest using the Assembly Linker (al.exe) utility. If i remember it correctly the CLR can load individual modules for an assembly, so that only the neccessary modules get loaded.

EDIT: Found a better description of the Netmodules and why you would want them.

There is another question here on SO that touches the checksum subject. The answers mentions using the GetILAsByteArray method for getting the IL.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon