MSDN Docs / .NET / API Reference / System.Reflection / Module

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

System.Reflection

Assembly

System.Reflection.dll

Inheritance

Object → System.Reflection.Module

Syntax
Properties
Methods
Constructors
public abstract class Module : System.Object
NameTypeAccessDescription
AssemblyAssemblygetGets the assembly that contains this module.
FullyQualifiedNamestringgetThe full path or location of the module.
ModuleVersionIdGuidgetThe GUID that uniquely identifies the version of this module.
NamestringgetThe simple name of the module.
ScopeNamestringgetThe name for the module scope.
SignatureDescription
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}");
        }
    }
}

See Also