Chapter 10: Managed Exception Monitoring


Overview

You might have guessed by now that Microsoft Visual Studio .NET development involves a lot more exceptions than traditional Microsoft Win32 development. The beauty of .NET is that exception handling was built in right from the beginning. It doesn't reflect the bolted and grafted feel for exceptions we've been wrestling with for the last umpteen years when working with Microsoft Windows applications and C++. Now exceptions are natural and fully supported.

As always, however, exceptions are for exceptional conditions. You don't want to use exceptions in place of constructs, such as switch and case statements, unless you're really into slow-moving code. In this chapter, I'll present a utility, ExceptionMon, that allows you to easily monitor the exceptions that occur in your application. Although you could always set all common language runtime (CLR) exceptions to stop when thrown in the debugger's exception dialog box, doing so would take forever because you'd have to do a ton of Continue-button pressing. With ExceptionMon, you can monitor the exceptions with almost no hassle.

ExceptionMon uses one of the coolest features of .NET, the Profiling API. I've written profilers and error detection tools without operating system support, and when I saw the .NET Profiling API, I immediately praised the development gods. The Profiling API is incredibly well thought out and works exactly as advertised. Its power allows you to see things that would essentially be impossible to view any other way. Interestingly, the name Profiling API is a little misleading because the Profiling API does so much more than allow you to time operations. By the end of the chapter, your head will be spinning with ideas for other advanced tools you can write with the Profiling API. In fact, I'll use the Profiling API in subsequent chapters as the basis for other cool tools.

Our journey to ExceptionMon will start with a discussion of the hows and whys of the Profiling API. After getting that out of the way, I'll explain how to use ExceptionMon and how it's implemented. Finally, I'll discuss exception usage as I see it in the .NET world.




Debugging Applications for Microsoft. NET and Microsoft Windows
Debugging Applications for MicrosoftВ® .NET and Microsoft WindowsВ® (Pro-Developer)
ISBN: 0735615365
EAN: 2147483647
Year: 2003
Pages: 177
Authors: John Robbins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net