Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleList the types defined in an assembly in VB .NET
DescriptionThis example shows how to list the types defined in an assembly in VB .NET
Keywordsassembly, type, data type, reflection, VB .NET
CategoriesVB.NET
 
If you enter or select a file's location and click the Go button, the prorgam creates an Assembly object that describes the location you entered. It then displays the Assembly's FullName value.

The program then loops through the collection returned by the Assembly's GetTypes method, displaying each defined type's name.

Note that the code must include the type Assembly in square brackets because "Assembly" is also a keyword.

 
Private Sub btnGo_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnGo.Click
    Dim assem As [Assembly] = _
        [Assembly].LoadFrom(txtPath.Text)
    txtResult.Text = assem.FullName()

    Dim txt As String = ""
    For Each defined_type As System.Type In assem.GetTypes()
        txt &= vbCrLf & defined_type.Name
    Next defined_type
    txtTypes.Text = txt.Substring(Len(vbCrLf))
End Sub
 
In addition to its main form Form1, the example program defines an Employee class, an Enum named DessertEnum, and a structure named Beverage. If you select the example's executable and click Go, the program lists these four types.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated