0

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 today 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?

Val
  • 930
  • 6
  • 10
Meh
  • 7,016
  • 10
  • 53
  • 76

1 Answers1

0

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

Community
  • 1
  • 1
Val
  • 930
  • 6
  • 10