AssemblyBuilder.DefineDynamicModule Method (String, String)
Defines a persistable dynamic module with the given name that will be saved to the specified file. No symbol information is emitted.
Assembly: mscorlib (in mscorlib.dll)
The name of the dynamic module. Must be less than 260 characters in length.
The name of the file to which the dynamic module should be saved.
name or fileName is null.
The length of name or fileName is zero.
The length of name is greater than or equal to 260.
fileName contains a path specification (a directory component, for example).
There is a conflict with the name of another file that belongs to this assembly.
This assembly has been previously saved.
This assembly was called on a dynamic assembly with Run attribute.
The caller does not have the required permission.
The assembly for default symbol writer cannot be loaded.
The type that implements the default symbol writer interface cannot be found.
If you want the module to contain the assembly manifest, name should be the same as the name of the assembly (that is, the AssemblyName.Name property of the AssemblyName used to create the dynamic assembly) and fileName should be the same as the filename you specify when you save the assembly.
In an assembly with only one module, that module should contain the assembly manifest.
To suppress optimizations when debugging dynamic modules, apply the DebuggableAttribute attribute to the dynamic assembly before calling DefineDynamicModule. Create an instance of DebuggableAttribute with the DisableOptimizations flag and apply it using the SetCustomAttribute method. The attribute must be applied to the dynamic assembly. It has no effect if applied to the module.
[Visual Basic, C#]
The code example below demonstrates how to create a persistent dynamic module using DefineDynamicModule.
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. ModuleBuilder myModuleBuilder = myAsmBuilder.DefineDynamicModule("MyModule3", "MyModule3.dll");
Available since 1.1