how to attach to debugger in-process  
Author Message
eran





PostPosted: Building Development and Diagnostic Tools for .Net, how to attach to debugger in-process Top

Hello,

I would like to catch all the excpetions in my application (handled + unhandled excpetion) and write to to a trace i have.

The catching should be in-process (from the executable code).

I know how catch the unhandled exceptions (registering to the event in the appDomain).

What i need to know is how to register to the HANDLED exceptions.

Many thanks,

Eran.




.NET Development2  
 
 
Mike Stall - MSFT





PostPosted: Building Development and Diagnostic Tools for .Net, how to attach to debugger in-process Top

The ability for a process to detect handled exceptions is very dangerous. The concept is called the Vectored Exception Handler on windows. You can do this in unmanaged code with kernel32!AddVectoredExceptionHandler, but it is not supported for managed code. See explanation here for details. Basically, it's too dangerous in managed. (My understanding is that you're asking what your options are with the current design; we can have a whole separate discussion about the design )

There's no easy way to detect all handled exceptions. If you want this, options include:
1. Use debugging interfaces, which must operate from a 2nd process. Example here.
2. Use profiler interfaces, which have callbacks for managed exceptions. This is hard too (profilers must be written in unmanaged code), but very powerful.
3. The rocket scientist approach is to use kernel32!AddVectoredExceptionHandler, but that's very dangerous and limited, and can't call back into managed code.



 
 
cgcrunner





PostPosted: Building Development and Diagnostic Tools for .Net, how to attach to debugger in-process Top

Hi Eran,

You may want to look at AVIcode's Intercept Studio. The product is designed to run from development to production and can monitor handled/unhandled exceptions and performance related bottlenecks.

Take care,

Chris