GetModule Method

MethodBuilder.GetModule Method ()

 

Returns a reference to the module that contains this method.

Namespace:   System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

public Module GetModule()

Return Value

Type: System.Reflection.Module

Returns a reference to the module that contains this method.

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

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);
}

.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Return to top
Show:
© 2016 Microsoft