本文整理汇总了VB.NET中System.Reflection.AssemblyName.AssemblyName构造函数的典型用法代码示例。如果您正苦于以下问题:VB.NET AssemblyName构造函数的具体用法?VB.NET AssemblyName怎么用?VB.NET AssemblyName使用的例子?那么, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Reflection.AssemblyName
的用法示例。
在下文中一共展示了AssemblyName构造函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: AssemblyName_Constructor
' 导入命名空间
Imports System.Reflection
Imports System.Threading
Imports System.Reflection.Emit
Public Class AssemblyName_Constructor
Public Shared Sub MakeAssembly(myAssemblyName As AssemblyName, fileName As String)
' Get the assembly builder from the application domain associated with the current thread.
Dim myAssemblyBuilder As AssemblyBuilder = Thread.GetDomain().DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.RunAndSave)
' Create a dynamic module in the assembly.
Dim myModuleBuilder As ModuleBuilder = myAssemblyBuilder.DefineDynamicModule("MyModule", fileName)
' Create a type in the module.
Dim myTypeBuilder As TypeBuilder = myModuleBuilder.DefineType("MyType")
' Create a method called 'Main'.
Dim myMethodBuilder As MethodBuilder = myTypeBuilder.DefineMethod("Main", MethodAttributes.Public Or MethodAttributes.HideBySig Or MethodAttributes.Static, GetType(object), Nothing)
Dim myILGenerator As ILGenerator = myMethodBuilder.GetILGenerator()
' Use the utility method to generate the IL instructions that print a string to the console.
myILGenerator.EmitWriteLine("Hello World!")
' Generate the 'ret' IL instruction.
myILGenerator.Emit(OpCodes.Ret)
' End the creation of the type.
myTypeBuilder.CreateType()
' Set the method with name 'Main' as the entry point in the assembly.
myAssemblyBuilder.SetEntryPoint(myMethodBuilder)
myAssemblyBuilder.Save(fileName)
End Sub
Public Shared Sub Main()
' Create a dynamic assembly with name 'MyAssembly' and build version '1.0.0.2001'.
Dim myAssemblyName As New AssemblyName()
myAssemblyName.Name = "MyAssembly"
myAssemblyName.Version = New Version("1.0.0.2001")
MakeAssembly(myAssemblyName, "MyAssembly.exe")
' Get all the assemblies currently loaded in the application domain.
Dim myAssemblies As [Assembly]() = Thread.GetDomain().GetAssemblies()
' Get the dynamic assembly named 'MyAssembly'.
Dim myAssembly As [Assembly] = Nothing
Dim i As Integer
For i = 0 To myAssemblies.Length - 1
If [String].Compare(myAssemblies(i).GetName().Name, "MyAssembly") = 0 Then
myAssembly = myAssemblies(i)
End If
Next i
If Not (myAssembly Is Nothing) Then
Console.WriteLine(ControlChars.Cr + "Displaying the assembly name" + ControlChars.Cr)
Console.WriteLine(myAssembly)
End If
End Sub
End Class
示例2: AssemblyNameDemo
' 导入命名空间
Imports System.Reflection
Public Class AssemblyNameDemo
Public Shared Sub Main()
' Create an AssemblyName, specifying the display name, and then
' print the properties.
Dim myAssemblyName As New _
AssemblyName("Example, Version=1.0.0.2001, Culture=en-US, PublicKeyToken=null")
Console.WriteLine("Name: {0}", myAssemblyName.Name)
Console.WriteLine("Version: {0}", myAssemblyName.Version)
Console.WriteLine("CultureInfo: {0}", myAssemblyName.CultureInfo)
Console.WriteLine("FullName: {0}", myAssemblyName.FullName)
End Sub
End Class
输出:
Name: Example Version: 1.0.0.2001 CultureInfo: en-US FullName: Example, Version=1.0.0.2001, Culture=en-US, PublicKeyToken=null