Setting Debug Options

 < Free Open Study > 



Before you begin debugging, you should set the debug options that you prefer in the .NET Options dialog box. To do this, select Tools Options. The Options dialog box will display. Click the Debug folder icon to get to the debugging options. The Debugging General Options dialog box will appear as shown in Figure 4-1.

click to expand
Figure 4-1: The Debugging General Options dialog box

There appear to be no options on the General tab that are of interest to us at this point. Click the Edit and Continue option. The Edit and Continue Options dialog box will appear as shown in Figure 4-2.

click to expand
Figure 4-2: The Edit and Continue Options dialog box

Edit and Continue, in the strictest sense, is limited to C/C++ programs. As previously described, the ability to change code and execute the changed code available in previous versions of Visual Basic does not exist in VB .NET or Visual C#. The traditional Edit and Continue feature isn't supported in Visual Studio .NET for Visual Basic or Visual C#. That isn't to say you can't change code while you're debugging either of these two languages. You simply cannot execute the changed code without stopping the debugging session and recompiling.

You need to select the action you want Visual Studio to take when you change code in a Visual Basic or Visual C# debugging session. You do this in the view shown in Figure 4-2.

First, check the Enable Edit and Continue check box. This will allow you to make changes and continue. Next are the two check boxes for allowing Visual Basic and Visual C# changes in the debugger:

Allow me to edit C# files while debugging: If you select this option, you will be allowed to edit files while debugging; however, Visual Studio cannot apply the code changes until you stop debugging, build a fresh version of the code, and restart the application. If you try to continue execution after editing code while debugging, the action that Visual Studio will take depends on the option that you select, which is discussed shortly.

Deselecting this option makes your files read-only so they cannot be edited while debugging.

Allow me to edit VB files while debugging: If you select this option, you will be allowed to edit files while debugging; however, Visual Studio cannot apply the code changes until you stop debugging, build a fresh version of the code, and restart the application. If you try to continue execution after editing code while debugging, the action that Visual Studio will take depends on the option that you select, which is discussed shortly. Deselecting this option makes your files read-only so they cannot be edited while debugging.

Finally, select one of the three option buttons to determine how Visual Studio will react to changes while debugging:

Warn me if I make changes: If you select this option, a dialog box will appear when you make changes when debugging that will allow you to continue or stop.

Always restart my program after I make changes: If you select this option, the debugger terminates execution of your program, builds a fresh version of the code, and restarts the program.

Always ignore changes and continue debugging: If you select this option, the debugger allows you to edit the code, but when you continue debugging, the debugger steps or continues execution in the old code (without the code changes).

My personal preference is to select the "Always ignore changes and continue debugging" option. This allows me to make the necessary changes while in the debugger and not lose my train of thought. I can still use the Immediate window to evaluate expressions or function calls, even though I can't execute the edited code. The "Always restart my program after I make changes" option is a little too drastic for me, because as soon as you make a change to a line of code, the debugger stops without warning and you lose any state that you may have achieved through a possibly lengthy process to get to where you are in the debugging session.



 < Free Open Study > 



Writing Add-Ins for Visual Studio  .NET
Writing Add-Ins for Visual Studio .NET
ISBN: 1590590260
EAN: 2147483647
Year: 2002
Pages: 172
Authors: Les Smith

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net