EnumBuilder.Module Property


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

Retrieves the dynamic module that contains this EnumBuilder definition.

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

public override Module Module { get; }

Property Value

Type: System.Reflection.Module

Read-only. The dynamic module that contains this EnumBuilder definition.



The following code sample demonstrates the use of the Module property to reference the parent module of the current EnumBuilder.

using System;
using System.Collections;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;

public class MyEnumBuilderSample
   static AssemblyBuilder myAssemblyBuilder;
   static ModuleBuilder myModuleBuilder;
   static EnumBuilder myEnumBuilder;

   public static void Main()
         CreateCallee(Thread.GetDomain(), AssemblyBuilderAccess.Save);
         Type[] myTypeArray = myModuleBuilder.GetTypes();
         foreach(Type myType in myTypeArray)
            Console.WriteLine("Enum Builder defined in the module builder is: " 
               + myType.Name);

         Console.WriteLine("Properties of EnumBuilder : ");
         Console.WriteLine("Enum Assembly is :" +  myEnumBuilder.Assembly.ToString());
         Console.WriteLine("Enum AssemblyQualifiedName is :" +  
         Console.WriteLine("Enum Module is :" +  myEnumBuilder.Module.ToString());
         Console.WriteLine("Enum Name is :" +  myEnumBuilder.Name.ToString());
         Console.WriteLine("Enum NameSpace is :" +  myEnumBuilder.Namespace);
      catch(NotSupportedException ex)
         Console.WriteLine("The following is the exception is raised: " + ex.Message);
      catch(Exception e)
         Console.WriteLine("The following is the exception raised: " + e.Message);

   private static void CreateCallee(AppDomain myAppDomain, AssemblyBuilderAccess access)
      // Create a name for the assembly.
      AssemblyName myAssemblyName = new AssemblyName();
      myAssemblyName.Name = "EmittedAssembly";

      // Create the dynamic assembly.
      myAssemblyBuilder = myAppDomain.DefineDynamicAssembly(myAssemblyName, 

      // Create a dynamic module.
      myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("EmittedModule", 

      // Create a dynamic Enum.
      myEnumBuilder = myModuleBuilder.DefineEnum("MyNamespace.MyEnum", 
                                 TypeAttributes.Public, typeof(Int32));

      FieldBuilder myFieldBuilder1 = myEnumBuilder.DefineLiteral("FieldOne", 1);
      FieldBuilder myFieldBuilder2 = myEnumBuilder.DefineLiteral("FieldTwo", 2);


.NET Framework
Available since 1.1
Available since 2.0
Return to top