Review: Peek at Someone Else's Code with Red Gate Reflector
When all you have is a DLL or an EXE, .NET Reflector will let you recreate C# or Visual Basic code from the assembly. But the real story here is the .NET Reflector integration with Visual Studio.
.NET Reflector is a decompiler and class browser that has helped developers examine .NET assemblies and methods since the launch of the Microsoft .NET Framework. The standalone tool lets you open a DLL or EXE and, assuming the assembly hasn't been obfuscated, recreate its C# or Visual Basic code. You can learn a lot from other people's code -- including code from Microsoft.
Originally developed by Lutz Roeder as a free tool, .NET Reflector was bought by Red Gate Software Ltd. in 2008. The size and speed of changes in the .NET Framework likely made it impossible for a single developer, working part time, to keep .NET Reflector up-to-date, let alone extend it in new ways.
Originally, Red Gate intended to continue to make the community edition of .NET Reflector available as a free standalone product and use it as a "loss leader" to drive sales of the Visual Studio add-ins and other Red Gate .NET and SQL Server products. Those "follow on" sales didn't materialize.
Red Gate now offers three "for purchase" versions of .NET Reflector 7, which shipped in March. The pricing for .NET Reflector 7 ranges from $35 for the standalone Windows app to $65 for the Visual Studio plug-in (VS), to $95 for a Visual Studio Professional add-in (VSPro) that supports debugging assemblies without the source code. (After an expiration strategy met resistance, Red Gate announced that .NET Reflector 6.x users can upgrade to the last free version, 6.8, which was released in May with a perpetual license.)
[Click on image for larger view.]
|Figure 1. Integration with Visual Studio: With .NET Reflector VSPro, you can treat decompiled code just like any other code for debugging purposes.|
Visual Studio Integration
While Red Gate has made .NET Reflector fully compatible with the .NET Framework 4, it's the integration with Visual Studio (in the VS and VSPro versions) that's the real step forward. For instance, to find the method you're working with, you no longer have to go searching through decompiled code. Now you can right-click on the method call and pick Open in .NET Reflector to explore the class in the .NET Reflector standalone UI.
But the real power is in VSPro when you're debugging code. Once you've decompiled the assembly (just right-click on the assembly in Solution Explorer), you get full debugging access to the decompiled code, including setting breakpoints, using Go To Definition and examining/setting variables. Speed can be an issue, however, because .NET Reflector decompiles the whole assembly, not just the class or method that you're invoking.
Installation isn't quite standard; there are no .msi or setup.exe files. Instead you run the Reflector.exe application, which asks you which version of the .NET Framework you want .NET Reflector to support. After starting .NET Reflector in standalone mode, you can turn on integration with as many versions of Visual Studio as you have installed. You can also activate Windows Explorer integration, which allows you to decompile assemblies by right-clicking on them in Windows Explorer.
Now that people are willing to pay money for .NET Reflector (or have no choice), other companies are entering the market. JetBrains is building a .NET decompiler (in preview now as the free standalone tool dotPeek) into its ReSharper product. And Telerik is introducing JustDecompile, currently in beta, as a free standalone tool later this summer. However, providing a better product than .NET Reflector is going to require hitting a moving target: Red Gate is currently issuing point releases every four weeks.
Red Gate Software Ltd.
Price: Standard $35; VS $65; VSPro $95
Quick Facts: Decompiles non-obfuscated assemblies into C# or Visual Basic code
Pros: The VSPro version integrates with Visual Studio and allows you to debug decompiled assemblies
Cons: Still, fundamentally, a standalone product with quick start options from Visual Studio
Peter Vogel is a principal in PH&V Information Services, specializing in Web development with expertise in SOA, client-side development, and user interface design. Peter tweets about his VSM columns with the hashtag #vogelarticles. His most recent book ("rtfm*") is on writing effective user manuals, and his blog on language and technical writing can be found at rtfmphvis.blogspot.com.