Debugging Managed Code
This section covers common debugging problems and techniques for managed applications, or applications written in languages that target the common language runtime, such as Visual Basic, C#, and C++. The techniques described here are high-level techniques. First look at the debugger.
In This Section
Diagnostic Messages in the Output Window
Describes the Debug and Trace classes, with which you can write run-time messages to the Output window. These classes include output methods that enable information output without breaking execution and information output that also breaks execution if a specified condition fails.
Assertions in Managed Code
Describes assertions in managed code, which test conditions that you specify as arguments to
Assert methods. In addition, this topic provides example code, information on using Debug and Trace class methods, considerations in Debug and Release versions of code, side effects, assert arguments, customizing assert behavior, and configuration files.
Stop Statements in Visual Basic
Stop statement, which provides an alternative to setting a breakpoint. Example code is also provided, along with comparisons between the
Stop statement and the
End statement, as well as between
Stop and the
Walkthrough: Debugging a Windows Form
Gives step-by-step instructions for creating a Windows Form and debugging that form. A Windows Form, a standard component of a managed Windows application, is one of the most common managed applications. This walkthrough uses Visual C# and Visual Basic, but the techniques for creating a Windows form with C++ are generally similar.
Debugging the OnStart Method
Provides code examples to allow you to debug the
OnStart method of a managed Windows service. To debug the
OnStart method of a Windows service, you must add a few lines of code to simulate the service.
Discusses debugging mixed-mode applications. This means any application that combines native code with managed code.
Error: Debugging isn't possible because a kernel debugger is enabled on the system
Describes an error message that occurs if you try to debug managed code on a Windows 7, Windows Vista, Windows XP, Windows 2000, or Windows NT system that has been started in debug mode.
JIT Optimization and Debugging
Describes the effects of JIT optimization on debugging.
Debugging LINQ and DLINQ
Discusses techniques for debugging LINQ queries.
Walkthrough: Debugging a Parallel Application
Describes how to use the Parallel Tasks and Parallel Stacks tool windows to debug a parallel application.
Find bugs faster and easier by recording your app's execution history with IntelliTrace. Step backward and forward through recorded events and calls to examine your app's state at key points in time. Debug your code without setting lots of breakpoints or restarting your app as frequently. Requires Visual Studio Enterprise.
Tracing and Instrumenting Applications
Describes tracing, a way for you to monitor the execution of your application while it is running, and instrumenting, which involves placing trace statements at strategic locations in your code. This topic also provides links to an introduction to instrumentation and tracing, trace switches, trace listeners, tracing code in an application, adding trace statements to application code, and compiling conditionally with Debug and Trace.
Debugging Windows Service Applications
Provides considerations for debugging Windows service applications, including setting up, attaching to the process, debugging the code in the service's
OnStart method and the code in the Main method, setting breakpoints, and using the Services Control Manager to start, stop, pause, and continue your service.
Debugging and Profiling
Discusses debugging .NET Framework applications and the configuration requirements.
Debugging Script and Web Applications
Describes common debugging problems and techniques you may encounter when debugging script and Web applications.