简体   繁体   中英

wpf unhandled exception

In my WPF application some users get "application generated an exception that can not handle" error. I've implemented Application.DispatcherUnhandledException event handler but the the exception isn't handled by this event. Is there any possibility that exception occurs outside application causing closing my application, maybe something with memory?

One thing you could try, in addition to the DispatcherUnhandledException is to listen for exceptions coming from the AppDomain

AppDomain.CurrentDomain.UnhandledException += 
        new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

This should, in theory, catch all exceptions related to your application and not just ones running within the Dispatcher.

您是否尝试将此添加到您的应用程序启动中?:

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

根据我的经验,如果只有一些用户得到错误(并且那些用户一直得到错误),那么很可能项目文件引用了dll而没有将'CopyToLocal'属性设置为true - 因此假设所有用户都有dll的安装在GAC中 - 某些用户可能不是这种情况。

If your handler is called but exception remains unhandled, it is necessary to handle the event: e.Handled=true; see: How to suppress UI exceptions in wpf?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM