Examine an Assembly for Types

Problem

You want to display all the types in an assembly.

Solution

Use the Assembly.GetTypes method.

Discussion

The Assembly.GetTypes method returns an array of Type objects that represent all the classes, interfaces, enumerations, and other types defined in an assembly. You can use this method in conjunction with the methods of the Type class (shown in recipe Examine a Type for Members) to "walk" the structure of an assembly.

The following example demonstrates a simple knock-off of the IL disassembler (ILDASM) included with the .NET Framework SDK. It’s a Windows application that allows the user to choose an assembly file and then displays a hierarchical tree that shows all the types it contains. Figure 9-1 shows the test ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.