Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
414
|
Chapter 7: Exception Handling
7.15 Breaking on a First-Chance Exception
Problem
You need to fix a problem with your code that is throwing an exception. Unfortu-
nately, an exception handler is trapping the exception, and you are having a tough
time pinpointing where and when the exception is being thrown.
Forcing the application to break on an exception before the application has a chance
to handle it is very useful in situations in which you need to step through the code at
the point where the exception is first being thrown. If this exception were thrown
and not handled by your application, the debugger would intervene and break on the
line of code that caused the unhandled exception. In this case, you can see the con-
text in which the exception was thrown. However, if an exception handler is active
when the exception is thrown, the exception handler will handle it and continue on,
preventing you from being able to see the context at the point where the exception
was thrown. This is the default behavior for all exceptions.
Solution
Select Debug Exceptions within Visual Studio 2005 to display the Exceptions dia-
log box (see Figure 7-1). Select the exception from the tree that you want to modify
and then click on the checkbox in the Thrown column in the list view. Click the OK ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Joe Mayo
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata