M
Mark Wilson
Is it possible to setup a custom unhandled exception handler in an Office
2007 addin?
I have an Outlook Exchange Client Extension and have added some code in the
IOutlookExtItemEvents::OnOpen method. Its sets up an exception handler and
then forces an exception. However, the exception handler never seems to get
called because the standard Windows Vista dialog pops up indicating that an
exception occurred.
Sample code is as follows:
STDMETHODIMP MyOutlookExtItemEvents::OnOpen(LPEXCHEXTCALLBACK lpeecb)
{
Crash();
return S_FALSE;
}
void Crash(void)
{
int nAnswer = MessageBox(GetFocus(), "Crash this program?", "OnOpen Test",
MB_ICONEXCLAMATION | MB_YESNO);
if (nAnswer == IDYES)
{
SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
int* ptr = 0;
*ptr = 0;
}
return;
}
LONG WINAPI MyUnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo)
{
MessageBox(GetFocus(),"EXCEPTION_CONTINUE_SEARCH", "OnOpen Test", MB_OK);
return EXCEPTION_CONTINUE_SEARCH;
}
I know that the crash and exception filter work because I can create a
console application that loads the DLL with LoadLibrary and calls Crash() by
using GetProcAddress. In that case, the message "EXCEPTION_CONTINUE_SEARCH"
displays before the Windows Vista exception dialog.
2007 addin?
I have an Outlook Exchange Client Extension and have added some code in the
IOutlookExtItemEvents::OnOpen method. Its sets up an exception handler and
then forces an exception. However, the exception handler never seems to get
called because the standard Windows Vista dialog pops up indicating that an
exception occurred.
Sample code is as follows:
STDMETHODIMP MyOutlookExtItemEvents::OnOpen(LPEXCHEXTCALLBACK lpeecb)
{
Crash();
return S_FALSE;
}
void Crash(void)
{
int nAnswer = MessageBox(GetFocus(), "Crash this program?", "OnOpen Test",
MB_ICONEXCLAMATION | MB_YESNO);
if (nAnswer == IDYES)
{
SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
int* ptr = 0;
*ptr = 0;
}
return;
}
LONG WINAPI MyUnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo)
{
MessageBox(GetFocus(),"EXCEPTION_CONTINUE_SEARCH", "OnOpen Test", MB_OK);
return EXCEPTION_CONTINUE_SEARCH;
}
I know that the crash and exception filter work because I can create a
console application that loads the DLL with LoadLibrary and calls Crash() by
using GetProcAddress. In that case, the message "EXCEPTION_CONTINUE_SEARCH"
displays before the Windows Vista exception dialog.