WPF MVVM Light 异常没有被 Application_DispatcherUnhandledException 捕获
我正在将 MVVM light 工具包用于 WPF 应用程序。不知何故,View/ViewModel 中抛出的任何异常都不会调用 Application_DispatcherUnhandledException 方法。仅当在加载第一个窗口(由 app.xaml 作为启动窗口加载)本身期间引发异常时,才会调用它......然后它就不会被命中。 还有其他人面临这个问题吗?
谢谢 安舒丽
Am using MVVM light toolkit for a WPF application. Somehow the Application_DispatcherUnhandledException method is not getting called for any exception thrown in the View/ViewModel. It gets called only if exception is thrown during load of the first Window(loaded by the app.xaml as the startup window) itself....then it simply doesn't get hit..
Anyone else facing this issue?
Thanks
Anshulee
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来异常可能不会发生在 UI 线程上。我不确定该框架在幕后正在做什么。无论如何,请检查一下:
http://www.codeproject.com/Articles /90866/Unhandled-Exception-Handler-For-WPF-Applications.aspx
非 UI 线程将抛出您的方法本身无法捕获的异常 - 您可能还想挂钩 AppDomain。
Sounds like the exception might not be occurring on the UI thread. I'm not sure what the framework is doing under the hood. Anyways, check this out:
http://www.codeproject.com/Articles/90866/Unhandled-Exception-Handler-For-WPF-Applications.aspx
Non-UI threads are going to throw exceptions that your method by itself won't catch - you'll probably want to hook the AppDomain as well.
在 MVVM Light 中,视图模型的异常不会在 UI 线程中抛出。下面的代码在 UI 线程中引发异常
信用转到这篇文章 http://codifying.wordpress.com/2010/12/20/silverlight-unhandled-exception-and-mvvm-light/
In MVVM Light the exception from view models are not thrown in UI thread. Below code raise exception in UI thread
Credit goes to this article http://codifying.wordpress.com/2010/12/20/silverlight-unhandled-exception-and-mvvm-light/