views:

52

answers:

2

I'm trying to create a top level exception capture for a debug version of some real-time data capture software and was wondering if there was a top-level exception handler similar to Application.ThreadException that captures ALL exceptions, not just unhandled/trapped ones.

Thanks in advance

+2  A: 

ALL exceptions inherit System.Exception. This would be your top-level that you can trap on.

Russ
Right, but I was asking specifically for already handled exceptions. Probably should have been more clear, but this was essentially for real time/ uninterrupted logging. Upped for my ambiguity
Ayubinator
+4  A: 

If you only want to be notified of all exceptions, you can use the AppDomain.FirstChanceException event.

Note: This is only available in .NET 4.0.

Ani
Nice option--but is only for .NET 4.0 and up.
Russ
I believe the only *other* answer is to actually write a debugger and have it attach to the process being monitored. This is likely more difficult than upgrading to .NET 4.0. :)
Stephen Cleary
Agreed, only a debugger could get the first chance notification. A program cannot debug itself.
Hans Passant