Chapter 7. Handling Exceptions and Debugging
In This Chapter
Using
Try...Catch...Finally
blocksThrowing exceptions
Viewing exceptions in Exception Assistant
Setting breakpoints and stepping through code
Using the Watch window to view data
Debugging code generated by Visual Studio
Anyone who has done even a little coding has been deflated by seeing the Visual Studio Debugger open instead of a beautiful masterpiece — because of an error that occurs in the program code. Sometimes, you spend more time with the Visual Studio Debugger than you do writing code. Of course, you might see less of the Debugger if you start using structured exception handling to capture exceptions when they do occur. And this chapter shows you how to do just that.
This chapter provides you with a full view of the Debugger. For example, you discover the wonders of using breakpoints to control when Visual Studio pauses your code and lets you debug it. You can also read how the Watch window works. All these tools can make your debugging significantly easier.
Structured Exception Handling to the Rescue
Whether you're writing code as a professional or a hobbyist, you want your code to perform as advertised. For example, when a user clicks a button to load information from a file, you want to make sure that file is there. If the file isn't there, you need to have some way to deal with the error.
In object-oriented programming (OOP), errors are often called exceptions. An exception is just what it sounds like — anything that ...
Get Visual Studio® 2010 All-in-One For Dummies® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.