|
|
Title | List the types defined in an assembly in VB .NET |
Description | This example shows how to list the types defined in an assembly in VB .NET |
Keywords | assembly, type, data type, reflection, VB .NET |
Categories | VB.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.
|
|
|
|
|
|