BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Stepping through the precompiled assemblies with .NET Reflector

Stepping through the precompiled assemblies with .NET Reflector

This item in japanese

Bookmarks

Debugging precompiled assemblies without any source code and PDB files is not easy without proper instrumentation. Red Gate’s .NET Reflector can decompile the assembly on-the-fly in Visual Studio and then step through it as if debugging an assembly with a source code.

.NET Reflector’s Visual Studio integration (in VS and VSPro editions) is what most people really should know about. The standard built-in Object browser shows only public methods and classes (Picture 1), while .NET Reflector Object Browser (Picture 2) goes deeper into precompiled assemblies and enables users to browse internal classes, methods and the code. Red Gate’s .NET Reflector Visual Studio add-in does decompilation on-the-fly. To debug precompiled assemblies, users should right click an assembly in Solution Explorer and choose "Enable debugging". This will tell .NET Reflector to generate a PDB file. But first it will try to locate a corresponding PDB file on a local machine and use it. When PDB file is created, users are ready to step through the code of the assembly, set breakpoints and use regular debugging techniques (Picture 4).

(Click on the image to enlarge it)

Picture 1. Built-in object browser

(Click on the image to enlarge it)

Picture 2. .NET Reflector Object Browser

Picture 3. Enabling precompiled assembly debugging

(Click on the image to enlarge it)

Picture 4: Debugging precompiled assembly

Having that kind of instrumentation inside a Visual Studio may seriously reduce the time spent diagnosing the problems in third-party libraries.

InfoQ reporter Jonathan Allen writes,

On multi-team projects the other consulting firms often send me precompiled assemblies without any source code. With the other team on the wrong side of the country, or even the world, communication delays can cost me a day or more. I tried Reflector's debugger support and was amazed at how well it worked. I was able to self-diagnose the problem and get my test servers up and running in a fraction of the time.

I only have two complaints at this time. First, it was unable to process the C++ CLI assemblies. For those I had to use JetBrain's dotPeek. Secondly, there is no clear way to open an arbitrary assembly when debugging without a solution file. I could attach to a running process easy enough, but to actually see anything I needed to trigger an exception. From there I was able to navigate up and down the stack and set break points where I actually wanted them."

.NET Reflector is supported by a number of add-ins and Red Gate has recently integrated the popular PowerCommands add-in from Jason Haley directly into the Reflector (Picture 5).

Picture 5: PowerCommands

Red Gate’s .NET Reflector is commercial grade software. It is regularly updated to keep up with new technologies and tools. On July 22 .NET Reflector 7.6.0.808 became available for download.

Sergey Barskiy, a .NET developer who’s been using Reflector for many years, writes,

I was pretty excited when 7.6 came out. This release of Reflector is about supporting new technology. There’s a lot of exciting things being released by Microsoft at the moment – Windows 8 and the WinRT libraries, Visual Studio 2012, .NET 4.5, and C# 5 with its new async functionality. Reflector 7.6 supports them all.

After making .NET Reflector a commercial product with the release of .NET Reflector 7 on 14 March 2011, Red Gate immediately got several competitors distributing their software for free: JetBrains DotPeek, Telerik JustDecompile, ILSpy and CodeReflect.

JetBrains DotPeek (Picture 6) is one of the most advanced .NET decompilers. It has good code generation quality, and it will try to fetch code from source servers if it’s available. DotPeek’s navigation features and keyboard shortcuts are very convenient. It has accurate search for symbol usages and supports plugins. DotPeek does not include Visual Studio integration.

(Click on the image to enlarge it)

Picture 6. DotPeek

Telerik JustDecompile is a free commercially supported .NET Decompiler with good code generation quality. It can create a project containing the generated code for the decompiled assembly. JustDecompile has robust search capabilities with full text search and a search for symbol usages. It also has a plug-in system with two extensions available from Telerik Website. JustDecompile has no Visual Studio integration.

(Click on the image to enlarge it)

Picture 7. JustDecompile

(Click on the image to enlarge it)

Picture 8. JustDecompile’s search dialog

ILSpy is the only free and open source .NET decompiler distributed under the MIT License. ILSpy’s code generation and syntax highlight are good. It can save one file or create a project containing all files for the decompiled assembly. ILSpy is a standalone tool without Visual Studio integration.

(Click on the image to enlarge it)

Picture 9. ILSpy

CodeReflect has nothing to add to its major free and commercial competitors. It’s commercially maintained .NET decompiler with an ascetic set of features. ItsCodeReflect‘s code generation and syntax highlight are very basic. It can’t save a file or create a project. Users can only copy decompiled code from CodeReflect. No and it has no support for Visual Studio integration.

(Click on the image to enlarge it)

Picture 10. CodeReflect

Whether users agree to pay for Visual Studio integration or they don't, they’ve got a good choice of free and paid .NET docompilers on the market.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Design of Visual Studio

    by Max Mustermann,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Oh, that's the first time I saw a screenshot of the new VisualStudio design.
    Really? Are they serious?

    Who wants to work with these colors?
    Why is everything the same color (almost black)?

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT