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.
Preventing Unhandled Exceptions
|
391
Discussion
Handle any user-defined exceptions that are unique to a specific COM/COM+ com-
ponent by trapping the
COMException exception. This class reflects COM/COM+
HRESULTs that have no mapping to managed exceptions.
The
COMException has a property, ErrorCode, in addition to those properties in the
base
Exception class. This property contains the HRESULT value that the COM/COM+
object returned. Another difference between
COMException and Exception is that the
InnerException property of a COMException object will always be null.
See Also
See the “Error Raising and Handling Guidelines” and “Handling COM Interop
Exceptions” topics in the MSDN documentation.
7.10 Preventing Unhandled Exceptions
Problem
You need to make absolutely sure that every exception thrown by your application is
handled and that no exception is bubbled up past the outermost exception handler.
Hackers often use these types of exceptions to aid in their analysis of the vulnerabili-
ties of a web application for instance.
Solution
Place try-catch or try-catch-finally blocks in strategic places in your application.
In addition, use the exception event handler as a final line of defense against unhan-
dled exceptions.
Discussion
If an exception occurs and is not handled, it will cause your application ...
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

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata