Partilhar via


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#, J#, and C++. The techniques described here are high-level techniques. For more information, see Common Language Runtime Overview or Using 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
    Describes the 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 Assert statement.
  • 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.
  • Mixed-Mode Debugging
    Discusses debugging mixed-mode applications. This means any application that combines native code with managed code.
  • 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.
  • /ASSEMBLYDEBUG
    Describes a linker option that adds DebuggableAttribute to code written with C++. This attribute is needed to use debugging features such as attach with C++.
  • 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 Home Page
    Provides links to the larger sections of the debugging documentation. Information includes what's new in the debugger, settings and preparation, breakpoints, handling exceptions, edit and continue, debugging managed code, debugging Visual C++ projects, debugging COM and ActiveX, debugging DLLs, debugging SQL, and the user interface references.

See Also

Tasks

Walkthrough: Debugging Custom Windows Forms Controls at Design Time

Concepts

Debugger Security

Other Resources

Debugging in Visual Studio