I know this is frowned upon, but I’m out of options here. I’m developing a C++/CLI app that has a bug that I’m unable to track down – mainly because it’s bypassing my current crash handler:
AppDomain::CurrentDomain->UnhandledException += gcnew UnhandledExceptionEventHandler(&LogAndExit);
Application::ThreadException += gcnew ThreadExceptionEventHandler(&LogAndExit);
Application::SetUnhandledExceptionMode(UnhandledExceptionMode::CatchException);
try
{
Application::Run(gcnew frmMain());
}
catch (Exception^ ex)
{
LogAndExit(ex);
}
catch (...)
{
LogAndExit();
}
Standard .NET crash handling, I suppose. MSDN reports that some of the CRT exceptions will blow over the managed stack and silently abort the app.
I’ve been reading up on _set_invalid_parameter_handler, but even though I’m getting a LNK2001 error, it seems it can’t be used with /clr:pure. Am I right, or am I just PEBKACing it up and missing a lib file?
Can you run in
/clrmode? If you can then try this:Then:
Another thing to note: if your application is multi-threaded, then you will only catch an exception from the thread in which
frmMain()is running. So doing a catch-all on your entire application is impossible in that case!