How to Debug and Decompile .NET Code with Net Reflector 8
Net Reflector 8 is a powerful tool that allows you to decompile, browse, and analyze any .NET assembly to C#, VB.NET, or IL. You can also debug your own code or third-party libraries using the Visual Studio debugger, and see how data flows through a library or component. In this article, we will show you how to use Net Reflector 8 to debug and decompile .NET code.
Net Reflector 8
Installing Net Reflector 8
To install Net Reflector 8, you need to download it from the Redgate website. You can choose between the Standard edition or the VSPro edition, which includes the Visual Studio integration and the Reflector Object Browser. The installation process is simple and straightforward. You can also activate a free trial or enter your license key if you have one.
Using Net Reflector 8 Desktop Application
The Net Reflector 8 desktop application allows you to explore and navigate decompiled code. You can open any .NET assembly or executable by clicking on the File menu and choosing Open. You can also drag and drop files into the application window. Once you open an assembly, you will see its contents in a tree view on the left pane. You can expand the nodes to see the namespaces, types, methods, properties, fields, events, etc. You can also search for a specific item using the search box on the top right corner.
On the right pane, you will see the decompiled code of the selected item in your chosen .NET language. You can switch between C#, VB.NET, or IL using the tabs on the bottom right corner. You can also change the language settings by clicking on the Tools menu and choosing Options. You can customize various aspects of the decompilation process, such as renaming variables, showing XML documentation comments, generating regions, etc.
One of the useful features of Net Reflector 8 is the on-hover hex/decimal value conversion. If you hover over a hexadecimal or decimal value in the decompiled code, you will see its equivalent value in the other format. This can help you understand some of the magic numbers in the code.
Another useful feature is the local variable highlighting. If you click on a local variable in the decompiled code, all its occurrences will be highlighted in yellow. This can help you track how a variable is used and modified throughout a method.
A new feature in Net Reflector 8 is the Code Map view. This view shows you a graphical representation of the dependencies between types and methods in an assembly. You can access it by clicking on the View menu and choosing Code Map. You can zoom in and out using the mouse wheel or the slider on the bottom left corner. You can also drag and drop items to rearrange them. You can click on an item to see its decompiled code on the right pane.
Using Net Reflector 8 Visual Studio Extension
If you have installed the VSPro edition of Net Reflector 8, you can also use it inside Visual Studio. This allows you to debug any decompiled assemblies as if they were your own, using the Visual Studio debugger. To enable this feature, you need to click on the Tools menu and choose Options. Then go to Debugging > General and uncheck Enable Just My Code (Managed only). Then go to Debugging > Symbols and click on Add... under Symbol file (.pdb) locations. Browse to C:\\ProgramData\\Red Gate\\.NET Reflector\\Desktop\\10.0\\Debugging folder and click OK.
Once you have done this, you can start debugging your application as usual. When you hit a breakpoint or step into a decompiled assembly, you will see its source code in Visual Studio. You can use all the debugging features that you normally use, such as inspecting variables, setting watches, evaluating expressions, etc.
A handy feature of Net Reflector 8 is that it generates .pdb files for decompiled assemblies and saves them in a cache folder. This means that you only need to enable debugging once for each assembly, and it will remember your settings for future sessions. 29c81ba772