I'm developing a Word Add-in using WPF windows. I'm using an UnhandledExceptionFilter to catch any unhandled exceptions so that Word doesn't throw an error message.
Dispatcher.CurrentDispatcher.UnhandledExceptionFilter += new DispatcherUnhandledExceptionFilterEventHandler(Dispatcher_UnhandledExceptionFilter);
void Dispatcher_UnhandledExceptionFilter(object sender, DispatcherUnhandledExceptionFilterEventArgs e)
{
e.RequestCatch = false;
// Display error message and close the window.
}
My event is fired correctly and I can display the appropriate error message box. However, for certain exceptions (e.g. null pointer exception in the window code), the exception is still being thrown to the calling class. While other exceptions (e.g. EndpointNotFoundException thrown from another helper class used in the window) is caught in my event and not rethrown.
Any thoughts? Thanks.
I asked an initial question about how to catch unhandled exceptions, but now I have this additional problem.
Catch C# WPF unhandled exception in Word Add-in before Microsoft displays error message