ASP.NET
  Home arrow ASP.NET arrow Page 4 - More on Testing and Debugging an ASP.NET 2...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

More on Testing and Debugging an ASP.NET 2.0 Application
By: Murach Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 8
    2006-05-18

    Table of Contents:
  • More on Testing and Debugging an ASP.NET 2.0 Application
  • How to use the debugger
  • How to use tracepoints
  • How to control the execution of an application

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    More on Testing and Debugging an ASP.NET 2.0 Application - How to control the execution of an application


    (Page 4 of 4 )


     
    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.

    Commands in the Debug menu and toolbar


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

    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.

    How to use the Autos, Locals, and Watch windows to monitor variables
     
    If you need to see the values of several application variables or properties, you can do that using the Autos, Locals, or Watch windows. By default, these windows are displayed in the lower left corner of the IDE when an application enters break mode. If they’re not displayed, you can display them by selecting the appropriate command from the Debug->Windows menu. Note that you can display up to four separate Watch windows.

    The content of the Autos, Locals, and Watch windows is illustrated in figure 4-13. The difference between the Autos and Locals windows is in the amount of information they display and the scope of that information.

    The Locals window displays information about the variables and controls within the scope of the current method. Since that includes information about the form and all of the controls on the form if the code in a form is currently executing, that information can be extensive.

    In contrast, the Autos window displays information about the variables, properties, and constants used in the current statement, the three statements before that statement, and the three statements after that statement. Although the information in this window is more limited than the information shown in the Locals window, the Autos window helps you focus on the variables that are relevant to the current statement.

    Unlike the Autos and Locals windows, the Watch windows let you choose the values that are displayed. The Watch window shown in this figure, for example, displays the Text property of the txtQuantity and lblUnitPrice controls, the Quantity property of the item object, and the UnitPrice property of the Product object that’s stored in the item object. The Watch windows also let you watch the values of expressions you specify. Note that an expression doesn’t have to exist in the application for you to add it to a Watch window.

    To add an item to a Watch window, you can type it directly into the Name column. Alternatively, if the item appears in the Code Editor window, you can highlight it in that window and then drag it to a Watch window. You can also highlight the item in the Code Editor or a data tip and then right-click on it and select the Add Watch command to add it to the Watch window that’s currently displayed.

    Besides displaying the values of variables and properties, you can use the Autos, Locals, and Watch windows to change these values. To do that, you simply double-click on the value you want to change and enter a new value. Then, you can continue debugging or continue the execution of the application.

    The Autos window


    Figure 4-13.  How to use the Autos, Locals, and Watch windows to monitor variables

    The Locals window

    A Watch window

    Description

    1. The Autos window displays information about variables, properties, and constants in the current statement and the three statements before and after the current statement.
    2. The Locals window displays information about the variables and controls within the scope of the current method.
    3. The Watch windows let you view the values of variables and expressions you specify, called watch expressions. You can display up to four Watch windows.
    4. To add a watch expression, type a variable name or expression into the Name column, highlight a variable or expression in the Code Editor window and drag it to the Watch window, or right-click on a variable or highlighted expression in the Code Editor window or a data tip and choose Add Watch.
    5. To delete a row from a Watch window, right-click the row and choose Delete Watch. To delete all the rows in a Watch window, right-click the window and choose Select All to select the rows, then right-click and choose Delete Watch.
    6. To display any of these windows, click on its tab if it’s visible or select the appropriate command from the Debug->Windows menu.
    7. To change the value of a property or variable from any of these windows, double-click on the value in the Value column, then type a new value and press the Enter key.

    Please check back next week for the conclusion of this article.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This article is an excerpt from the book "Murach's ASP.NET 2.0 Web Programming with...
     

    Buy this book now. This article is excerpted from chapter four of the book Murach's ASP.NET 2.0 Web Programming with VB 2005, written by Joel Murach and Anne Boehm (Murach, 2006; ISBN: 1890774324). Check it out today at your favorite bookstore. Buy this book now.

    ASP.NET ARTICLES

    - Developing a Mini ASP.NET AJAX Server Centri...
    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT