MethodBuilder.GetModule Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Returns a reference to the module that contains this method.

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

Public Function GetModule As Module

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.


 Dim myModBuilder As ModuleBuilder = myAsmBuilder.DefineDynamicModule("MathFunctions")

 Dim myTypeBuilder As TypeBuilder = myModBuilder.DefineType("MyMathFunctions", _
			TypeAttributes.Public)

 Dim myMthdBuilder As MethodBuilder = myTypeBuilder.DefineMethod("Adder", _
MethodAttributes.Public, GetType(Integer), _
New Type() {GetType(Integer), GetType(Integer)})

 ' Create body via ILGenerator here ...

 Dim myNewType As Type = myTypeBuilder.CreateType()

 Dim myModule As [Module] = myMthdBuilder.GetModule()

 Dim myModTypes As Type() = myModule.GetTypes()
 Console.WriteLine("Module: {0}", myModule.Name)
 Console.WriteLine("------- with path {0}", myModule.FullyQualifiedName)
 Console.WriteLine("------- in assembly {0}", myModule.Assembly.FullName)
 Dim myModType As Type
 For Each myModType In  myModTypes
    Console.WriteLine("------- has type {0}", myModType.FullName)
 Next myModType

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