Export (0) Print
Expand All

AssemblyBuilder.DefineDynamicModule Method

Defines a dynamic module in this assembly.

Overload List

Defines a named transient dynamic module in this assembly.

[Visual Basic] Overloads Public Function DefineDynamicModule(String) As ModuleBuilder
[C#] public ModuleBuilder DefineDynamicModule(string);
[C++] public: ModuleBuilder* DefineDynamicModule(String*);
[JScript] public function DefineDynamicModule(String) : ModuleBuilder;

Defines a named transient dynamic module in this assembly and specifies whether symbol information should be emitted.

[Visual Basic] Overloads Public Function DefineDynamicModule(String, Boolean) As ModuleBuilder
[C#] public ModuleBuilder DefineDynamicModule(string, bool);
[C++] public: ModuleBuilder* DefineDynamicModule(String*, bool);
[JScript] public function DefineDynamicModule(String, Boolean) : ModuleBuilder;

Defines a persistable dynamic module with the given name that will be saved to the specified file. No symbol information is emitted.

[Visual Basic] Overloads Public Function DefineDynamicModule(String, String) As ModuleBuilder
[C#] public ModuleBuilder DefineDynamicModule(string, string);
[C++] public: ModuleBuilder* DefineDynamicModule(String*, String*);
[JScript] public function DefineDynamicModule(String, String) : ModuleBuilder;

Defines a persistable dynamic module, specifying the module name, the name of the file to which the module will be saved, and whether symbol information should be emitted using the default symbol writer.

[Visual Basic] Overloads Public Function DefineDynamicModule(String, String, Boolean) As ModuleBuilder
[C#] public ModuleBuilder DefineDynamicModule(string, string, bool);
[C++] public: ModuleBuilder* DefineDynamicModule(String*, String*, bool);
[JScript] public function DefineDynamicModule(String, String, Boolean) : ModuleBuilder;

Example

The code example below demonstrates how to create a persistent dynamic module with symbol emission using DefineDynamicModule.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of DefineDynamicModule. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Dim myAppDomain As AppDomain = Thread.GetDomain()
Dim myAsmName As New AssemblyName()
myAsmName.Name = "MyAssembly"
Dim myAsmBuilder As AssemblyBuilder = myAppDomain.DefineDynamicAssembly(myAsmName, _
                      AssemblyBuilderAccess.Run)
' Create a dynamic module that can be saved as the specified DLL name. By
' specifying the third parameter as true, we can allow the emission of symbol info.
Dim myModuleBuilder As ModuleBuilder = myAsmBuilder.DefineDynamicModule("MyModule4", _
                              "MyModule4.dll", _
                              True)

[C#] 
AppDomain myAppDomain = Thread.GetDomain(); 
AssemblyName myAsmName = new AssemblyName();
myAsmName.Name = "MyAssembly";
AssemblyBuilder myAsmBuilder = myAppDomain.DefineDynamicAssembly(
                     myAsmName,
                     AssemblyBuilderAccess.Run);
// Create a dynamic module that can be saved as the specified DLL name. By
// specifying the third parameter as true, we can allow the emission of symbol info.
ModuleBuilder myModuleBuilder = myAsmBuilder.DefineDynamicModule("MyModule4",
                                 "MyModule4.dll",
                                  true);

[C++] 
AppDomain*  myAppDomain = Thread::GetDomain();
AssemblyName* myAsmName = new AssemblyName();
myAsmName->Name = S"MyAssembly";
AssemblyBuilder*  myAsmBuilder = myAppDomain->DefineDynamicAssembly(myAsmName,
   AssemblyBuilderAccess::Run);
// Create a dynamic module that can be saved as the specified DLL name. By
// specifying the third parameter as true, we can allow the emission of symbol info.
ModuleBuilder*  myModuleBuilder = myAsmBuilder->DefineDynamicModule(S"MyModule4",
   S"MyModule4.dll",
   true);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

AssemblyBuilder Class | AssemblyBuilder Members | System.Reflection.Emit Namespace

Show:
© 2014 Microsoft