I have a project that consists of a C# application that calls into a couple of C++/CLI DLLs. If I have a Visual Studio C Runtime Library fatal error in the native code, there appears to be no way to catch it.
To give a simple example, if I put this in the native code:
wchar_t buf; ::wcscpy_s(buf, 1, L"ab");
The app will crash (in release builds). It doesn't throw an exception and I can't catch it with __try…__except.
I'd like to catch these kinds of errors so I can display a nice error dialog, ideally with a callstack. I'd settle for creating a minidump, but I tried creating a minidump by calling ::SetUnhandledExceptionFilter() in one of the C++/CLI DLLs but that doesn't appear to work either.
Is there any way to gracefully handle a C Runtime Library fatal error in a .NET application?