Catching Exceptions in WPF at the FrameWork Level

前端 未结 2 1443
清酒与你
清酒与你 2021-01-14 16:28

I\'m developing a light-weight WPF MVVM framework, and would like to be able to catch unhandled exceptions, and ideally recover from them.

Ignoring for the moment al

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-14 17:12

    The reason VS shows you the exception is because you have set it up like that (either you did this explicitly or - more likely - the defaults in VS configured it like this). You can control what Visual Studio does when it encounters an exception in the debugged code through the Debug->Exceptions menu.

    You can even make it break even though you have a catch for it which is quite handy in some cases.

    If you're not using multi threading then you should be fine with the DispatcherUnhandledException event since it will catch everything that gets uncaught on the main UI thread.

提交回复
热议问题