Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Browsing objects using ObjectReflector.Net

0.00/5 (No votes)
6 Apr 2007 1  
Browse any object using ObjectReflector.Net at runtime

DownloadObjectReflector.Net source code from CodePlex

Introduction

Which developer doesn't use Visual Studio Watcher and browse properties and fields values to debug his application? I think the response is No one.

However, imagine that you have not visual studio installed and something is going wrong with your application. Logging will be the solution of course, but how much data will application logs? Can you log all properties and fields values of all your objects? The response is definitively no.

ObjectReflector.Net can be the way for debugging applications at the user's desktops side.

Here a screen shot of what you can browse with ObjectReflector.Net :

Screenshot - ObjectReflector.jpg

Using the code

Using ObjectReflector.Net requires a single line of code. Begin by adding a reference to ObjectReflector.Dll, drag the ucBrowser from your Visual Studio toolbox to a form and add this line of c# in your code :

myBrowser.DataSource = this; //This line will allow you to browse the form it self

The left panel of the browser control allows enabling/disabling some options :

- Show NonPublic members : Checking this option will show all properties and fields including private and protected ones.

- Show Static members : Static properties and fields are shown/hidden depeding on the checkstate of the checkbox.

- Sort memeber by name : If checked, properties and fields are sorted by name before they are displayed in the treeview.

History

- 4/6/2007: ObjectReflector.Net article submitted.

Conclusion

Reflection is one of most powerfull features in the .Net framework. ObjectReflector.Net is a good sample i hope for those who don't discover reflection yet.

Regards,

Hayder Marzouk

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here