MethodBuilder.GetModule Method

Definition

Returns a reference to the module that contains this method.

C#
public System.Reflection.Module GetModule();

Returns

Returns a reference to the module that contains this method.

Examples

The sample code below illustrates the usage of the GetModule method to retrieve information about a dynamically-generated module.

C#
ModuleBuilder myModBuilder = myAsmBuilder.DefineDynamicModule("MathFunctions");

TypeBuilder myTypeBuilder = myModBuilder.DefineType("MyMathFunctions",
                TypeAttributes.Public);

MethodBuilder myMthdBuilder = myTypeBuilder.DefineMethod("Adder",
                MethodAttributes.Public,
                typeof(int),
                new Type[] { typeof(int),
                         typeof(int) });

// Create body via ILGenerator here ...

Type myNewType = myTypeBuilder.CreateType();

Module myModule = myMthdBuilder.GetModule();

Type[] myModTypes = myModule.GetTypes();
Console.WriteLine("Module: {0}", myModule.Name);
Console.WriteLine("------- with path {0}", myModule.FullyQualifiedName);
Console.WriteLine("------- in assembly {0}", myModule.Assembly.FullName);
foreach (Type myModType in myModTypes)
    {
    Console.WriteLine("------- has type {0}", myModType.FullName);
}

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1