Producing Mini Dumps for _caught_ SEH exceptions in mixed code DLL

Posted by Assaf Lavie on Stack Overflow See other posts from Stack Overflow or by Assaf Lavie
Published on 2010-04-26T08:40:30Z Indexed on 2010/04/26 8:43 UTC
Read the original article Hit count: 411

Filed under:
|
|
|
|

I'm trying to use code similar to clrdump to create mini dumps in my managed process.

This managed process invokes C++/CLI code which invokes some native C++ static lib code, wherein SEH exceptions may be thrown (e.g. the occasional access violation).

  C# WinForms
  -> 
    C++/CLI DLL
    ->
      Static C++ Lib
      ->
        ACCESS VIOLATION

Our policy is to produce mini dumps for all SEH exceptions (caught & uncaught) and then translate them to C++ exceptions to be handled by application code. This works for purely native processes just fine; but when the application is a C# application - not so much.

The only way I see to produce dumps from SEH exceptions in a C# process is to not catch them - and then, as unhandled exceptions, use the Application.ThreadException handler to create a mini dump. The alternative is to let the CLR translate the SEH exception into a .Net exception and catch it (e.g. System.AccessViolationException) - but that would mean no dump is created, and information is lost (stack trace information in Exception isn't as rich as the mini dump).

So how can I handle SEH exceptions by both creating a minidump and translating the exception into a .Net exception so that my application may try to recover?

© Stack Overflow or respective owner

Related posts about c#

Related posts about c++