List of classes in the assembly

I have a DLL assembly in which there are different classes. Each class has about 50-100 members and 4-5 functions. How to create a list of all classes and their corresponding members using the VB.NET program?

I need to show the user the operation using a specific class.

+5
source share
5 answers
+2
source

Assuming your assembly is loaded in thisAsm (in this ex I use a running assembly),

This will give you all non-abstract classes:

Assembly thisAsm = Assembly.GetExecutingAssembly();
List<Type> types = thisAsm.GetTypes().Where(t => t.IsClass && !t.IsAbstract).ToList();

, .

(, , IYourInterface, )

Assembly thisAsm = Assembly.GetExecutingAssembly();
List<Type> types = thisAsm.GetTypes().Where
            (t => ((typeof(IYourInterface).IsAssignableFrom(t) 
                 && t.IsClass && !t.IsAbstract))).ToList();

, , , GetProperties() GetMethods() .

+16

, Form VB.net:

Dim thisAsm As Assembly = Assembly.GetExecutingAssembly()
Dim types As List(Of Type) = thisAsm.GetTypes().Where(Function(t) t.BaseType = GetType(Form)).ToList()
+1

vb.net, @amazedsaint:

Dim thisAsm As Assembly = Assembly.GetExecutingAssembly()
Dim types As List(Of Type) = thisAsm
    .GetTypes()
    .Where(Function(t) t.IsClass AndAlso Not t.IsAbstract).ToList()

Dim thisAsm As Assembly = Assembly.GetExecutingAssembly()
Dim types As List(Of Type) = thisAsm
    .GetTypes()
    .Where(Function(t) ((GetType(IYourInterface).IsAssignableFrom(t) AndAlso t.IsClass AndAlso Not t.IsAbstract))).ToList()
0

. ( # ).

-2

All Articles