All pastes #162280 Raw Edit

Something

public text v1 · immutable
#162280 ·published 2006-09-06 10:48 UTC
rendered paste body
using System;
using System.Reflection;
using System.IO;

namespace ClassExplorer
{
    public class ClassExplorer
    {
        public static void Explore(string strPath)
        {
            //string assemblyPath = "";
            Type[] types;
            Assembly assemblyObject;

            foreach (string dllFile in Directory.GetFiles(strPath, "*.dll"))
            {

                try
                {                    
                    assemblyObject = Assembly.LoadFrom(dllFile);

                    try
                    {
                        types = assemblyObject.GetTypes();
                        foreach (Type t in types)
                        {
                            Console.WriteLine(t.FullName);
                        }
                    }

                    catch (ReflectionTypeLoadException ex)
                    {
                        string msg = "";

                        foreach (Exception e in ex.LoaderExceptions)
                        {
                            if (e.Message != null) msg += e.Message + Environment.NewLine;
                        }
                        msg = "GetMyTypes() threw a TypeLoadException" + Environment.NewLine + msg;
                        Console.WriteLine(msg);
                    }

                    catch (Exception e)
                    {

                        Console.WriteLine(e.ToString());
                        Console.WriteLine(e.InnerException.ToString());
                    }
                }

                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    Console.WriteLine(e.InnerException.ToString());
                }
            }
        }

        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Please provide a path. For example the current path: ClassExplorer .");
            }
            else
            {
                ClassExplorer.Explore(args[0]);
            }
        }
    }
}