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(AssemblyTitleAttribute)
ctor = attributeType.GetConstructor(ctorParameters)
ctorArgs = New Object() { "The Application Title" }
attribute = New CustomAttributeBuilder(ctor, ctorArgs)
myAssembly.SetCustomAttribute(attribute)
myAssembly.DefineVersionInfoResource()
myAssembly.Save(assemName.Name & ".exe")
End Sub
End Module
|