Just noticed Assembly.LoadModule()
in intellisense. I see it returns a reference to the basically undocumented Module class.
I know reflection pretty well and I've never heard of modules? What are they? the name is tantalizing.
An assembly can consist of multiple modules and even be split up into multiple files.
There are two primary use cases for using modules:
Modules are in part an artifact of a time when the .NET team believed it was important for users to be able to download assemblies over the network to their local machine for execution.
To save bandwidth, an assembly can be split up into multiple files, each containing a module. The assembly file containing the primary or main module contains an assembly manifest that lists the location of all other assembly files. This allows a developer to ensure a fast initial download of the main assembly and the runtime loads Types or Resources from other modules in the assembly on demand.
If you're curious, you can actually instruct the C# compiler to spit out a modules and compile them manually with the assembly linker. Here's a tutorial on MSDN.
Most assemblies today are single-module assemblies containing only a main module. Unless you write code dealing with Reflection (or raw IL) for a living (I did some time back), you'll be fine if you just do assembly.MainModule
whenever required. I'm pretty sure the number of people using multil-file/multi-module is ɛ (only marginally larger than 0).