当前位置: 首页>>代码示例>>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;未经允许,请勿转载。