Follow me on Twitter at
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:
Simple Reflection in .NET Whidbey - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on Web, HTML5, Mobile, Xamarin.iOS, Xamarin.Android, and Windows Azure.


Visual Studio Magazine Column Personal Blog


Book Authors




Georgia Tech Bloggers



Simple Reflection in .NET Whidbey

Here is some simple Reflection code that I wrote to see what is in some .NET assemblies.  Suggestions are welcome.  Its not very "Whidbey-esque," but it gets the job done.


string strDotNetDir = @".......";

string strSql = String.Empty;

string strCn = ".....";

string strTypeOfType = String.Empty;

Assembly b = Assembly.LoadFrom(strDotNetDir + "System.Data.dll");


SqlConnection sqlCn = new SqlConnection(strCn);

SqlCommand sqlCm = new SqlCommand();


Type [] types = b.GetTypes ();

MethodInfo[] methods;

Type[] tInterfaces;

string[] strNames;

sqlCm.Connection = sqlCn;

sqlCm.CommandType = CommandType.Text;


foreach (Type t in types) {

      if ( t.IsPublic )


            if (t.IsClass)


            methods = t.GetMethods();

            foreach(MethodInfo m in methods)


            //store the methods that were found.



            strTypeOfType = "Class";


        if (t.IsEnum)


            strNames = Enum.GetNames(t);

            foreach (string s in strNames)


               //store the Enum names.


            strTypeOfType = "Enum";


        if (t.IsInterface)


            tInterfaces = t.GetInterfaces();

            foreach (Type t2 in tInterfaces)


               //store the interface(s) that were found.


            strTypeOfType = "Interface";


        if (strTypeOfType != String.Empty)


         //do something with what you found as far as the type.


        strTypeOfType = String.Empty;



if ( sqlCn.State != ConnectionState.Closed )





sqlCn = null;


sqlCm = null;


Posted: Sep 24 2004, 08:43 PM by Wallym | with no comments
Filed under:


Patrick Steele said:

One suggestion: Get a new naming convention! Hungarian notation is so 20th-century. :)
# September 27, 2004 11:18 AM