当前位置: 代码迷 >> C# >> 关于WPF全局错误捕获的有关问题
  详细解决方案

关于WPF全局错误捕获的有关问题

热度:389   发布时间:2016-04-28 08:43:30.0
关于WPF全局异常捕获的问题
WPF程序中出现下图所示错误:

使用wpf捕获全局异常的方式不活不到吗?

//处理未捕获的异常   
//Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
 //处理UI线程异常   
 Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

 //处理非UI线程异常   
 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

------解决思路----------------------
试试这个SetUnhandledExceptionFilter
如果还不行,就要写个c的库来调用

public delegate int UnhandledExceptionCallBack(ref long a);
[DllImport("kernel32")]
private static extern int SetUnhandledExceptionFilter(UnhandledExceptionCallBack f);
  相关解决方案