2
Answers

Modules in .NET

Vipul Kelkar

Vipul Kelkar

14y
2.4k
1

Hi friends
What exactly is a module when we say there are multiple modules in the assemblies and we use the get modules method in reflection.What actually does it retrieve
Thanks
Answers (2)
1
Jaish Mathews

Jaish Mathews

NA 7.3k 1.2m 14y

 

Theory

A module is a portable executable file, such as type.dll or application.exe, consisting of one or more classes and interfaces. There may be multiple namespaces contained in a single module, and a namespace may span multiple modules.

One or more modules deployed as a unit compose an assembly.

Note that a .NET Framework module is not the same as a module in Visual Basic, which is used by a programmers to organize functions and subroutines in an application.

http://msdn.microsoft.com/en-us/library/system.reflection.module.aspx
Practical Example
We have a solution with 2 projects with classes
1st project has below classes. This is a new WindowsForm project
public partial class Form1 : Form
{
}
2nd project has below class. This is a new clas library
public class Class2 
 {
}
Now build solution as it will build our 2 projects
Below is the code to get the Module name for our 1st project class and you will get "WindowsFormsApplication1.exe" ,  project compiled file name
   Form1 frm = new Form1();
  Module m1 = frm.GetType().Module;
Below is the code to get the Module name for our 2nd project class and you will get "ClassLibrary1.dll" ,  project compiled file name
Class2 c1 = new Class2();
 Module m = c1.GetType().Module;
 

0
Vipul Kelkar

Vipul Kelkar

NA 1.9k 405.3k 14y
hey thanks jaish..the explanation was helpful