Debugging Programs

Even the greatest programmers make mistakes, so a good debugger is of paramount importance. Debugging with Visual Studio is very easy, and you have a wide range of options for stopping programs and examining code. The simplest is to debug code as you are building it. The debugger can also trap an unhandled error condition and attach itself to the offending process, or you can explicitly attach the debugger to a process. Let's examine the simple case first.

To debug the program, it must be built in Debug mode. Select this using the project Configuration Manager selectable from the main Debug … menu. Figure 1.5.21 shows the Configuration Manager and illustrates the use of the drop-down menus for selecting the build configuration ...

Get C# and the .NET Framework: The C++ Perspective now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.