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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vipul KelkarPosted May 10, 2010, 6:30 AM
Jaish MathewsPosted May 10, 2010, 6:24 AM
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;