加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 使用AvalonDock 2.0时未处理的’System.ComponentModel.Wi

发布时间:2020-12-15 07:54:35 所属栏目:百科 来源:网络整理
导读:我正在使用 AvalonDock 2.0,当我打开一个dock容器时,在调试模式下应用程序崩溃(它在没有调试的情况下运行时工作正常).我得到以下异常: An unhandled exception of type ‘System.ComponentModel.Win32Exception’ occurred in WindowsBase.dll Additional i
我正在使用 AvalonDock 2.0,当我打开一个dock容器时,在调试模式下应用程序崩溃(它在没有调试的情况下运行时工作正常).我得到以下异常:

An unhandled exception of type ‘System.ComponentModel.Win32Exception’
occurred in WindowsBase.dll

Additional information: The operation completed successfully

我遇到了这个answer,建议取消选中Exception Settings中的方框.有线的事情是它第一次使用它.但它不再存在了.我试过其他机器也不行.任何有关如何解决此问题的建议.
Avalon代码(第5行引发的异常)

protected override IntPtr WndProc(IntPtr hwnd,int msg,IntPtr wParam,IntPtr lParam,ref bool handled) {
            if (msg == Win32Helper.WM_WINDOWPOSCHANGING) {
                if (_internalHost_ContentRendered) {
                    // the below line throw the exception
                    Win32Helper.SetWindowPos(_internalHwndSource.Handle,Win32Helper.HWND_TOP,Win32Helper.SetWindowPosFlags.IgnoreMove | Win32Helper.SetWindowPosFlags.IgnoreResize);
                }
            }
            return base.WndProc(hwnd,msg,wParam,lParam,ref handled);
        }

解决方法

显然有一个 issue提交,但直到现在没有回应.

因此,作为一种解决方法,我使用App.xaml.cs中的Application.DispatcherUnhandledException处理了任何未处理的异常.
有关详细信息,请查看answer.
码:

protected override void OnStartup(StartupEventArgs e) {
     base.OnStartup(e);
     this.DispatcherUnhandledException += AppGlobalDispatcherUnhandledException;
}

private void AppGlobalDispatcherUnhandledException(object sender,System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) {
     e.Handled = true;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读