7

我正在使用AvalonDock 2.0,当我打开一个停靠容器时,在调试模式下应用程序崩溃(它在没有调试的情况下运行良好)。我得到以下异常:

WindowsBase.dll 中出现“System.ComponentModel.Win32Exception”类型的未处理异常

附加信息:操作成功完成

我遇到了这个答案,它建议取消选中异常设置中的复选框。有线的事情是它第一次使用它就起作用了。但它不再。我在其他机器上试过,它也不起作用。有关如何解决此问题的任何建议。
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, 0, 0, 0, 0, Win32Helper.SetWindowPosFlags.IgnoreMove | Win32Helper.SetWindowPosFlags.IgnoreResize);
                }
            }
            return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
        }
4

3 回答 3

3

显然有一个问题已提交,但直到现在都没有回应。

因此,作为一种解决方法,我使用Application.DispatcherUnhandledException处理了任何未处理的异常App.xaml.cs
请检查此答案以获取更多详细信息。
代码:

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;
}
于 2016-06-19T08:42:48.310 回答
1

对于登陆此页面的其他人,我可以通过关闭以下设置来解决问题:

工具 > 选项 > 调试 > 常规 > 为 XAML 启用 UI 调试工具

于 2016-10-07T17:42:25.737 回答
1

我的快速破解是我在调试配置期间禁用了 LayoutAutoHideWindowControl 类中的 UpdateWindowPos()。

    internal void Show(LayoutAnchorControl anchor)
    {
        if (_model != null)
            throw new InvalidOperationException();

        _anchor = anchor;
        _model = anchor.Model as LayoutAnchorable;
        _side = (anchor.Model.Parent.Parent as LayoutAnchorSide).Side;
        _manager = _model.Root.Manager;
        CreateInternalGrid();

        _model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_model_PropertyChanged);

        Visibility = System.Windows.Visibility.Visible;
        InvalidateMeasure();
#if !DEBUG
        UpdateWindowPos();
#endif
        Trace.WriteLine("LayoutAutoHideWindowControl.Show()");
    }

根据我目前的经验,这只会导致无法拖放最小化的可停靠容器。

于 2017-01-17T10:03:48.137 回答