Coping Without Edit and Continue

As I discussed in some detail during Chapter 1, perhaps the most noticeable loss within the Source window is the inability to edit your code during a debugging run and then continue execution of the new code without restarting the program (a feature sometimes referred to as Edit and Continue, or E&C). If you select the option Tools Options Debugging Edit and Continue Allow me to edit VB files while debugging, you'll be able to edit your source code during program execution, but this revised code is ignored by the compiler until you restart the program. This is actually rather dangerous, as it's very easy to become confused about what code you've changed and what code is actually executing.

If you do want to take advantage of this ability to change code during a program run, I suggest adding all new and revised code into one or more separate procedures that you can then enclose within a collapsible region using the #Region #End Region directive. The #Region directive allows you to remove the new code from your view so that it doesn't interfere with your view of the code that is currently executing.

Placing the new code into separate procedures, maybe including revised copies of current procedures, is necessary because the #Region directive can only be used at a class or namespace level. Unfortunately, you can't place a region directive within a procedure or function. An alternative to creating a new dummy procedure just for gaining the benefits of a collapsible region is to place the new code into a comment code, as a comment block is automatically created as a collapsible region.

Having placed the code into one or more regions and collapsed these regions so that new code can't be seen, you should mark each region with a bookmark by right-clicking the left column of the source window and selecting "Add task list shortcut". You can see and reference these bookmarks in the Task window by opting to show "All tasks " (or just "Shortcuts" if you prefer) from its context menu.

After the current debugging run has finished, double-clicking each of these shortcuts in the Task window takes you directly to the associated region where new code is stored. You can then amend your code to incorporate all of the new changes before restarting your program.

Comprehensive VB .NET Debugging
Comprehensive VB .NET Debugging
ISBN: 1590590503
EAN: 2147483647
Year: 2003
Pages: 160
Authors: Mark Pearce © 2008-2017.
If you may any questions please contact us: