O'Reilly logo

Professional Visual Basic 2012 and .NET 4.5 Programming by Todd Herman, Gastón Hillar, David McCarter, Rob Windsor, Billy Hollis, Bill Sheldon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6

Exception Handling and Debugging

What's in this chapter?

The general principles behind exception handling

The Try…Catch…Finally structure for trapping exceptions

How to send exceptions to other code using the Throw statement

Obtaining information about an exception by using the exception object's methods and properties

Event logging and simple tracing, and how you can use these methods to obtain feedback about how your program is working

Wrox.com Code Downloads for this Chapter

The wrox.com code downloads for this chapter are found at www.wrox.com/remtitle.cgi?isbn=9781118314456 on the Download Code tab. The code file name is MainWindow.xaml.vb and is located in the chapter 6 folder.

Production quality applications need to handle unexpected conditions. In .NET this is done with the structured exception syntax. When an unexpected condition arises .NET does not generate error codes. Instead when an unexpected condition occurs, the CLR creates a special object called an exception. This object contains properties and methods that describe the unexpected condition in detail and provide various items of useful information about what went wrong.

This chapter covers how structured exception handling works in Visual Basic. It discusses the common language runtime (CLR) exception handler in detail and illustrates some programming methods that are efficient when catching exceptions.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required