See Your Own (.NET) Reflection

Two posts in one week?! Ney, two posts in one night! This must be some kind of record!

I thought I’d mention a nice little .NET tool from Lutz Roeder, called the .NET Reflector. This tool is one of my personal favorites because it allows you to take any .NET assembly and view the source code directly in your language of choice, all thanks to the CIL. (If you are using .NET and don’t yet know what CIL is, you may want to look it up).

Screenshot of .NET Reflector (taken from Lutz Roeder's site)Because all .NET languages are essentially compiled into the same CIL code, the .NET Reflector provides the ability to”disassemble” that same CIL code into C#, VB.NET, Managed C++ and several others.

So, why would you ever want to peer into a pre-built assembly file? For starters, you can now look into any class, method or property provided by the .NET Framework (or any other .NET DLL). Curious why an event is firing within your DataGridView object, despite what the documentation says? Check out the source code! Ever wonder how exactly the Convert methods work? Check out the source code!

I even came across an instance at work where I had a .NET assembly where the source code had become lost (don’t ask how). With this tool, I just had to load up the assembly in the .NET Reflector tool and I had my complete source code right there (sans the comments).

Roeder has a few other tools on his site that I have yet to try. If anybody has used one and found it useful, let me know.

Leave a Reply

Your email address will not be published. Required fields are marked *