System.Reflection.Module Class
Overview
The System.Reflection.Module
class provides access to the metadata of a module within an assembly. A module is a portable executable file that contains IL code and resources.
Namespace
Assembly
System.Reflection.dll
Inheritance
Object → System.Reflection.Module
Syntax
Properties
Methods
Constructors
public abstract class Module : System.Object
Name | Type | Access | Description |
---|---|---|---|
Assembly | Assembly | get | Gets the assembly that contains this module. |
FullyQualifiedName | string | get | The full path or location of the module. |
ModuleVersionId | Guid | get | The GUID that uniquely identifies the version of this module. |
Name | string | get | The simple name of the module. |
ScopeName | string | get | The name for the module scope. |
Signature | Description |
---|---|
Type[] GetExportedTypes() | Returns an array of types exported from the module. |
MethodInfo GetMethod(string name) | Retrieves a method with the specified name. |
FieldInfo GetField(string name) | Retrieves a field with the specified name. |
CustomAttributeData[] GetCustomAttributesData() | Gets data about the custom attributes applied to the module. |
bool IsDefined(Type attributeType, bool inherit) | Determines whether one or more instances of attributeType are applied to this module. |
Module is an abstract class; you cannot directly instantiate it. Instances are obtained from Assembly objects.
Remarks
A module can contain one or more types and resources. Most .NET assemblies consist of a single module, but multi‑file assemblies contain multiple modules, each stored in its own file.
Example
using System;
using System.Reflection;
class Demo
{
static void Main()
{
Assembly asm = Assembly.GetExecutingAssembly();
Module mod = asm.GetModules()[0];
Console.WriteLine($"Module Name: {mod.Name}");
Console.WriteLine($"Full Name: {mod.FullyQualifiedName}");
Console.WriteLine($"Version GUID: {mod.ModuleVersionId}");
Console.WriteLine("Exported Types:");
foreach (var t in mod.GetExportedTypes())
{
Console.WriteLine($" - {t.FullName}");
}
}
}