Decompiling C# DLL's with Reflector for .NET
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.
