Define the assembly's only module. For a single-file assembly, the module name is the assembly name.
Imports System
Imports System.Reflection
Imports System.Reflection.Emit
Module Example
Sub Main()
Dim assemName As New AssemblyName()
assemName.Name = "EmittedAssembly"
Dim myAssembly As AssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemName,AssemblyBuilderAccess.Save)
Dim attributeType As Type = GetType(AssemblyFileVersionAttribute)
Dim ctorParameters() As Type = { GetType(String) }
Dim ctor As ConstructorInfo = attributeType.GetConstructor(ctorParameters)
Dim ctorArgs() As Object = { "2.0.3033.0" }
Dim attribute As New CustomAttributeBuilder(ctor, ctorArgs)
myAssembly.SetCustomAttribute(attribute)
attributeType = GetType(AssemblyProductAttribute)
ctor = attributeType.GetConstructor(ctorParameters)
attribute = New CustomAttributeBuilder(ctor, _
New Object() { "My Product Name" })
myAssembly.SetCustomAttribute(attribute)
'
Dim myModule As ModuleBuilder = _
myAssembly.DefineDynamicModule(assemName.Name, _
assemName.Name & ".exe")
myAssembly.DefineVersionInfoResource()
myAssembly.Save(assemName.Name & ".exe")
End Sub
End Module
Related examples in the same category