Listing Types and Methods of assembly, Reflection

Some time there can be requirment in which we need to list the types and methods of assembly. For that purpose we have to use the reflection with help of that we can get all the details of the assembly even the IL code also. one samle to list the Types, associated methods and there properties is given below

//Get the assembly object                
Assembly assembly = Assembly.LoadFrom(openFileDlg.FileName);

//List them all                
foreach (Type type in assembly.GetTypes())
    //Create a node of types first                     
    TreeNodetreeNode = assemblyTreeView.Nodes.Add(type.Name);

    foreach (MethodInfo mthdInfo in type.GetMethods())
        //Get the node as method name                        
        TreeNodemethodNode = treeNode.Nodes.Add(mthdInfo.Name);

        //List the details of the method as child node
        methodNode.Nodes.Add("Return Type : " +
        methodNode.Nodes.Add("IsAbstract : " +
        methodNode.Nodes.Add("Access Modifier : " +
            (mthdInfo.IsPublic ? "Public" : "Private"));
        methodNode.Nodes.Add("IsStatic : " +

It is not limited to this much even you can create a type out of it and even can invoke methods of those type. This can be very useful when you want to create instance of class at runtime after locating in the various assemblies

1 comment
  1. Подскажите шооблончег под WordPress 2.6.2, чтобы был похож на ваш

    Заранее благодарю)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: