Visual Studio 2005 provides many new debugging features, that simplify the testing and debugging process. We discuss some of these features in this section.
C.5.1. Edit and Continue
The Edit and Continue feature allows you to make modifications or changes to your code in debug mode, then continue executing the program without having to recompile your code.
Figure C.22. Setting a breakpoint at line 19.
Figure C.23. Changing the text of the input prompt while the application is in Debug mode.
Figure C.24. Application prompt displaying the updated text.
In this example, we wanted to make a change in the text for our input prompt before line 19 executes. However, if you want to make a change to a line that already executed, you must select a prior statement in your code from which to continue execution.
Figure C.25. Setting a breakpoint at line 21.
Figure C.26. Stopping execution at the breakpoint in line 21.
Figure C.27. Setting the next statement to execute.
Figure C.28. Program execution continues with updated prompt text.
Certain types of change are not allowed with the Edit and Continue feature once the program begins execution. These include changing class names, adding or removing method parameters, adding public fields to a class and adding or removing methods. If a particular change that you make to your program is not allowed during the debugging process, Visual Studio displays a dialog box as shown in Fig. C.29.
Figure C.29. Dialog box stating that certain program edits are not allowed during program execution.
C.5.2. Exception Assistant
Another new feature in Visual Studio 2005 is the Exception Assistant. You can run a program by selecting either Debug > Start Debugging or Debug > Start Without Debugging. If you select the option Debug > Start Debugging and the runtime environment detects uncaught exceptions, the application pauses, and a window called the Exception Assistant appears indicating where the exception occurred, the type of the exception and links to helpful information on handling the exception. We discuss the Exception Assistant in detail in Section 12.4.3.
C.5.3. Just My Code™ Debugging
Throughout this book, we produce increasingly substantial programs that often include a combination of code written by the programmer and code generated by Visual Studio. The IDE-generated code can be difficult for novices (and even experienced programmers) to understandfortunately, you rarely need to look at this code. Visual Studio 2005 provides a new debugging feature called Just My Code™, that allows programmers to test and debug only the portion of the code they have written. When this option is enabled, the debugger will always step over method calls to methods of classes that you did not write.
You can change this setting in the debugger options. Select Tools > Options. In the Options dialog, select the Debugging category to view the available debugging tools and options. Then click the checkbox that appears next to the Enable Just My Code (Managed only) option (Fig. C.30) to enable or disable this feature.
Figure C.30. Enabling the Just My Code debugging feature in Visual Studio.
C.5.4. Other New Debugger Features
All of the features discussed thus far in this section are available in all versions of Visual Studio, including Visual C# 2005 Express Edition. The Visual Studio 2005 debugger offers additional new features, such as visualizers, tracepoints and more, which you can learn about at msdn.microsoft.com/vcsharp/2005/overview/debugger.
Preface
Index
Introduction to Computers, the Internet and Visual C#
Introduction to the Visual C# 2005 Express Edition IDE
Introduction to C# Applications
Introduction to Classes and Objects
Control Statements: Part 1
Control Statements: Part 2
Methods: A Deeper Look
Arrays
Classes and Objects: A Deeper Look
Object-Oriented Programming: Inheritance
Polymorphism, Interfaces & Operator Overloading
Exception Handling
Graphical User Interface Concepts: Part 1
Graphical User Interface Concepts: Part 2
Multithreading
Strings, Characters and Regular Expressions
Graphics and Multimedia
Files and Streams
Extensible Markup Language (XML)
Database, SQL and ADO.NET
ASP.NET 2.0, Web Forms and Web Controls
Web Services
Networking: Streams-Based Sockets and Datagrams
Searching and Sorting
Data Structures
Generics
Collections
Appendix A. Operator Precedence Chart
Appendix B. Number Systems
Appendix C. Using the Visual Studio 2005 Debugger
Appendix D. ASCII Character Set
Appendix E. Unicode®
Appendix F. Introduction to XHTML: Part 1
Appendix G. Introduction to XHTML: Part 2
Appendix H. HTML/XHTML Special Characters
Appendix I. HTML/XHTML Colors
Appendix J. ATM Case Study Code
Appendix K. UML 2: Additional Diagram Types
Appendix L. Simple Types
Index