How to Test and Debug an ASP.NET Application—How to control the execution of an application

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:Tutorials
ASP.NET Tutorials

How Test and Debug ASP.NET

© 2006 Mike Murach & Assoc.

How to control the execution of an application

Once you’re in break mode, you can use a variety of commands to control the execution of the application. These commands are summarized in figure 4-12. As you can see, most of these commands are available from the Debug menu or the Debug toolbar, but three of them are available only from the shortcut menu for the Code Editor window. You can also use shortcut keys to start some of these commands.

To execute the statements of an application one at a time, you use the Step Into command. When you use this command, the application executes the next statement, then returns to break mode so you can check the values of properties and variables and perform other debugging functions. The Step Over command is similar to the Step Into command, but it executes the statements in called methods without interruption (they are “stepped over”).

The Step Out command executes the remaining statements in a method without interruption. When the method finishes, the application enters break mode before the next statement in the calling method is executed.

To skip over code that you know is working properly, you can use the Run To Cursor or Set Next Statement command. You can also use the Set Next Statement command to rerun lines of code that were executed before an exception occurred. And if you’ve been working in the Code Editor window and have forgotten where the next statement to be executed is, you can use the Show Next Statement command to move to it.

If your application gets caught in a processing loop so it keeps executing indefinitely without generating a page, you can force it into break mode by choosing the Debug�Break All command. This command lets you enter break mode any time during the execution of an application.

Figure 4-12 How to control the execution of an application

Commands in the Debug menu and toolbar

Command Toolbar Keyboard Function
Start/Continue Image:HDAfig-4-12a.gif F5 Start or continue execution of the application.
Break All Image:HDAfig-4-12b.gif Ctrl+Alt+Break Stop execution and enter break mode.
Stop Debugging Image:HDAfig-4-12c.gif Shift+F5 Stop debugging and end execution of the application.
Restart Image:HDAfig-4-12d.gif Ctrl+Shift+F5 Restart the entire application.
Show Next Statement Image:HDAfig-4-12e.gif   Display the next statement to be executed.
Step Into Image:HDAfig-4-12f.gif F11 Execute one statement at a time.
Step Over Image:HDAfig-4-12g.gif F10 Execute one statement at a time except for called methods.
Step Out Image:HDAfig-4-12h.gif Shift+F11 Execute the remaining lines in the current method.

Commands in the Code Editor window’s shortcut menu

Command Function
Run to Cursor Execute the application until it reaches the statement that contains the insertion point.
Set Next Statement Set the statement that contains the insertion point as the next statement to be executed.
Show Next Statement Move the insertion point to the next statement that will be executed.

Description

• Once the application enters break mode, you can use the Step Into, Step Over, Step Out, and Run To Cursor commands to execute one or more statements and return to break mode.

• To alter the normal execution sequence of the application, you can use the Set Next Statement command. Just place the insertion point in the statement you want to execute next, issue this command, and click the Continue button to continue application execution.

• To stop an application that’s caught in a loop, switch to the Visual Studio window and use the Debug->Break All command.


Previous_Page_.gif Next_Page_.gif

Personal tools