Export (0) Print
Expand All

How to: Obtain Type and Member Information from an Assembly

Updated: December 2009

The System.Reflection namespace contains many methods for obtaining information from an assembly. This section demonstrates one of these methods. For additional information, see Reflection Overview.

The following example obtains type and member information from an assembly.

Imports System
Imports System.Reflection

Class Asminfo1
   
   Shared Sub Main()
      Console.WriteLine("Reflection.MemberInfo")
      
      'Get the Type and MemberInfo. 
      'Insert the fully qualified class name inside the quotation marks in the following statement.
      Dim MyType As Type = Type.GetType("System.IO.BinaryReader")
      Dim Mymemberinfoarray As MemberInfo() = MyType.GetMembers((BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Static Or BindingFlags.Instance Or BindingFlags.DeclaredOnly))
      
      'Get and display the DeclaringType method. 
      Console.Write(vbCrLf & "There are {0} documentable members in ", Mymemberinfoarray.Length)
      Console.WriteLine("{0}.", MyType.FullName)
      
      Dim Mymemberinfo As MemberInfo
      For Each Mymemberinfo In  Mymemberinfoarray
         Console.WriteLine(Mymemberinfo.Name)
      Next Mymemberinfo
   End Sub 
End Class 

Date

History

Reason

December 2009

In Visual Basic code, removed overloaded Sub Main and included line feeds as well as carriage returns.

Content bug fix.

Community Additions

ADD
Show:
© 2014 Microsoft