Disabling .NET handling of native exceptions

I have a C # application that calls a mixed version of C ++ dll. I turned on dumping through HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ Windows Error Reporting \ LocalDumps.

When the dll accesses invalid memory, the runtime converts the win32 exception into a managed exception System.AccessViolationException and unwinds the stack before dumping, destroying its own information about the stack. I could catch the exception myself before .net gets on it and generates a dump manually, but running the code in an already damaged program can hang it, according to msdn. So how can I disable SEH translation?

+4
source share
1 answer

You cannot disable this. The CLR does not unwind the stack unless you catch an exception. Make sure you do not. This should go through the AppDomain.UnhandledException event handler. The function you need is Marshal.GetExceptionPointers (), which will indicate an exception when opening the mini-disk.

In my answer you will find resources in this MSDN forum forum and this pinvoke.net snippet should be enough to dig yourself together.

+1
source

All Articles