Decompiling C# DLL's with Reflector for .NET

May
01
2007

A couple of days ago, I had a coding accident. I moved a couple of files into a subdirectory of a C# DLL project. I did a bit of work on things and needed to roll back to earlier code. So, I had Subversion do exactly that.

I moved on and built the project a couple of times. Then I went to look at one of those moved classes and discovered the disaster. Somewhere along the way, an entire days worth of work disappeared without getting committed into the repository. Actually, it was a hugely *productive* day of work that disappeared.

As I looked down the deep pit that my stomach fell into, I heard a voice in the back of my head saying, "Isn't it possible to decompile .NET DLL's and EXE's?" See, I *knew* for a fact that I'd compiled and committed the DLL in the interim.

Indeed it is. Unless someone goes to the effort to prevent it, all of the code is actually available in the DLL. However, I'd never needed to do this, so I went looking for a solution that wasn't in the "Enterprise" price class. Fortunately, I found Reflector for .NET, which, ironically, I'd already bookmarked for the Writer for .NET project on the same page a while back.

Instead of $2500 (the cost of one of the solutions I found), this baby is free. And it works. Oh, how well it works.

I've seen other decompilers for other languages and what you usually get is variables and methods named "widkriwp" instead of "GetUser", which leads to the joyous experience of trying to rename everything until it both works and makes sense. But, this resulted in pretty much my exact source code.

Variables, methods and class names were all intact, neatly indented with hyperlinks to trace method definitions back to their origins. In short, I pretty much had the exact thing I needed to restore the project to its previous state: a giant pile of spaghetti. But it's *functional* spaghetti and I could move on.

In short, this thing saved my hide. Of course, now I want to point it at every .NET DLL and EXE on my Windows workstations and peek at the insides.

 

Comments on this post

Feedback is always welcome. Read some from other folks or leave your own below. Just keep things civil and remember that what you post lives on in public. Forever.

Thanks,
J

Leave Your Own Comment

By submitting a comment, you agree to license it under the terms of the Creative Commons Attribution license.

© 2003-2008 J Wynia. All original content is licensed under the terms of the Creative Commons Attribution license unless otherwise noted. Content from other sources is licensed under its original terms.