當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET Assembly.GetExecutingAssembly方法代碼示例

本文整理匯總了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
開發者ID:VB.NET開發者,項目名稱:System.Reflection,代碼行數:22,代碼來源:Assembly.GetExecutingAssembly

輸出:

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
開發者ID:VB.NET開發者,項目名稱:System.Reflection,代碼行數:9,代碼來源:Assembly.GetExecutingAssembly

輸出:

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
開發者ID:VB程序員,項目名稱:System.Reflection,代碼行數:30,代碼來源:Assembly.GetExecutingAssembly


注:本文中的System.Reflection.Assembly.GetExecutingAssembly方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。