Can you add a handler for WPF event exceptions?
I have a single-threaded IronPython WPF application and if an event handler (FrameworkElement.SizeChanged
for example) throws, the exception is just eaten and execution continues without any kind of notification.
Because of this I spent a lot of time t开发者_运维知识库oday solving an "impossible" bug.
Does the same thing happen when using WPF from C#? What happens there if SizeChanged
throws?
And is there a way to globally catch exceptions thrown by event handlers, but which don't terminate the application?
A useful trick in c# for catching exceptions globally, is to wrap the entry point for your program in a try-catch block. Any unhandled exceptions will wind their way up to it. Depending on the nature of the exception, it may stop the program from terminating.
EDIT
Thought this might also be relevant to your interests.
WPF global exception handler
精彩评论