Archive

Archive for January, 2009

Finding types in a Running Program

January 30th, 2009 Anuraj P No comments

Once my project manager gives me a nice tool called .Net Reflector.(You can download it free from : http://www.red-gate.com/products/reflector/). .Net Reflector can be used to view .net assembly internals *. This tool makes me happy, because I can check how other developer implemented something, also you can choose your favorite VB.Net / C#. Few days back I come to know the technology or feature that used for getting the internals. It is Reflection. Here is some code, which helps to get the class information from an assembly.

Dim _assembly As Assembly = Assembly.GetExecutingAssembly
For Each _type As Type In _assembly.GetTypes
Debug.Print(_type.Name)
Next

The above code will return all the classes in the executing assembly. As I implemented this code in a Windows Forms application. It returns the following classes.

MyApplication
MyComputer
MyProject
MyForms
MyWebServices
ThreadSafeObjectProvider`1
InternalXmlHelper
RemoveNamespaceAttributesClosure
Form1
Resources
MySettings
MySettingsProperty

Happy Coding :)

Categories: .Net, .Net 3.0 / 3.5, Visual Studio Tags: