Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to get the count of classes and methods contained in a DLL


I know the ildasm.exe tool will show me, but in scenarios where i need to a manual check on 2 dll having count of namespaces,classess,methods etc.

Please suggest a best approach which can give me the count ?

What I have tried:

I tried illdasm.exe tool from Microsoft, trying out there would be a away to interact via commandline and the count from it
Posted
Updated 26-Apr-18 0:57am
v2

1 solution

ildasm.exe allows you to display a .NET module's contents, but AFAIK there is no statistical functionality built into it.

Fortunately, you can use objects in System.Reflection Namespace[^] to build your own program for that. You can search here on CP for "Reflection" and get plenty of examples about its usage.
 
Share this answer
 
Comments
Girish Kalamati 2-May-18 2:06am    
I wrote code for that but that fails even fails if you do not have all of the depenedent dlls in the same location.

Hint: keeping all dll in for a bigger product is not such easy

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

// Use reflection
using System.Reflection;


namespace Difference_Between_DLLs
{
    class Program
    {
        static void Main(string[] args)
        {
            int count_Entities=0;
            //Assembly assembly = Assembly.ReflectionOnlyLoadFrom(@"E:\~~~~~\your.DLL");
            Console.WriteLine("DLL Name: {0}",assembly.ManifestModule.Name);            
            Console.WriteLine("---------   Displaying the names of the Entities (Interfaces, Delegates, Classes, Enums/Properties etc.)   ------------");            
            foreach (var ti in assembly.ExportedTypes.ToArray())
            {                              
                Console.WriteLine(ti);
                count_Entities += 1;
            }
            Console.WriteLine("\n");
            Console.WriteLine("Total number of entities found : {0}", count_Entities);            
            Console.WriteLine("Press any button to close !");
            Console.ReadLine();
        }
    }
}
Girish Kalamati 2-May-18 2:07am    
Thanks @phil.o , can i achieve this via ILSPY tool ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900