Datasheet
Effectively using these debugging techniques can make finding problems in the code much easier, so
you should spend some time learning how to use these tools. They can mean the difference between
finding a tricky error in minute, hours, or days.
The commands visible in the Debug window change, depending on several conditions such as the type
of file you have open, whether the program is running, the line of code that contains the cursor, and
whether that line contains a breakpoint. This section discusses the menu items shown in Figure 1-21.
You will see other menus items under different circumstances.
The following list briefly describes the Debug menu’s commands.
❑ Windows — This submenu’s commands display other debugging-related windows. This sub-
menu is described in more detail in the following section, “The Debug\Windows Submenu.”
❑ Continue — This command resumes program execution. The program runs until it finishes, it
reaches another breakpoint, or you stop it.
❑ Break All — This command stops execution of all programs running within the debugger. This
may include more than one program if you are debugging more than one application at the
same time. This can be useful, for example, if two programs work closely together.
❑ Stop Debugging — This command halts the program’s execution and ends its debugging ses-
sion. The program stops immediately, so it does not get a chance to execute any cleanup code.
❑ Detach All — This command detaches the debugger from any processes to which it is attached.
Note that this does not stop those processes.
❑ Terminate All — This command terminates any processes to which the debugger is attached.
❑ Restart — This command stops the currently running process and restarts the startup project.
❑ Attach to Process — This command displays the dialog shown in Figure 1-22 to let you attach
the debugger to a running process. Select the process to which you want to attach and click
Attach.
❑ Exceptions — This command displays the dialog shown in Figure 1-23. If you check a Thrown
box, the debugger stops whenever the selected type of error occurs. If you check a User-
unhandled box, the debugger stops when the selected type of error occurs and the program
does not catch it with error handling code. For example, suppose that your code calls a sub-
routine that causes a divide-by-zero exception. Use the dialog to select Common Language
Runtime Exceptions/System/System.DivideByZeroException (use the Find button to find it
quickly). If you check the Thrown box, the debugger stops in the subroutine when the divide-
by-zero exception occurs even if the code is contained in an error handler. If you check the User-
unhandled box, the debugger stops only if no error handler is active when the error occurs.
23
IDE
571982 ch01_2.qxd 1/19/06 1:15 PM Page 23