本文整理匯總了VB.NET中System.Reflection.Assembly.GetExecutingAssembly方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Assembly.GetExecutingAssembly方法的具體用法?VB.NET Assembly.GetExecutingAssembly怎麽用?VB.NET Assembly.GetExecutingAssembly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Reflection.Assembly
的用法示例。
在下文中一共展示了Assembly.GetExecutingAssembly方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
' 導入命名空間
Imports System.Reflection
Public Module Example
Public Sub Main()
' Get the assembly from a known type in that assembly.
Dim t As Type = GetType(Example)
Dim assemFromType As Assembly = t.Assembly
Console.WriteLine("Assembly that contains Example:")
Console.WriteLine(" {0}", assemFromType.FullName)
Console.WriteLine()
' Get the currently executing assembly.
Dim currentAssem As Assembly = Assembly.GetExecutingAssembly()
Console.WriteLine("Currently executing assembly:")
Console.WriteLine(" {0}", currentAssem.FullName)
Console.WriteLine()
Console.WriteLine("The two Assembly objects are equal: {0}",
assemFromType.Equals(currentAssem))
End Sub
End Module
輸出:
Assembly that contains Example: GetExecutingAssembly1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null Currently executing assembly: GetExecutingAssembly1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null The two Assembly objects are equal: True
示例2: Main
' 導入命名空間
Imports System.Reflection
Module Example
Public Sub Main()
Dim assem As Assembly = GetType(Example).Assembly
Console.WriteLine("Assembly name: {0}", assem.FullName)
End Sub
End Module
輸出:
Assembly name: Assembly1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
示例3: Assembly.GetExecutingAssembly()
' 導入命名空間
Imports System.Reflection
Class A
End Class
Class B
End Class
Class C
End Class
Class D
End Class
Public Class MainClass
Public Shared Sub Main()
Dim ThisAssembly As [Assembly] = [Assembly].GetExecutingAssembly()
Dim TypeObj As Type
For Each TypeObj In ThisAssembly.GetTypes()
Console.WriteLine(TypeObj.Name)
Next
End Sub
End Class