C# 如何调试间歇性未处理的异常;必须断开指定子项与当前父项的连接;?

C# 如何调试间歇性未处理的异常;必须断开指定子项与当前父项的连接;?,c#,wpf,xaml,datepicker,unhandled-exception,C#,Wpf,Xaml,Datepicker,Unhandled Exception,我收到间歇性未处理异常必须断开指定子项与当前父项Visual的连接,然后才能附加到新父项Visual,但stacktrace仅引用System.*和MS.*调用。它看起来像是鼠标左键单击了一个日期选择器,试图切换弹出窗口(我猜是日历小部件)。此应用程序中有许多日期选择器。我不知道是哪一个导致了异常 我如何调试这个 UnhandledException: Must disconnect specified child from current parent Visual before attach

我收到间歇性未处理异常
必须断开指定子项与当前父项Visual的连接,然后才能附加到新父项Visual
,但stacktrace仅引用System.*和MS.*调用。它看起来像是鼠标左键单击了一个日期选择器,试图切换弹出窗口(我猜是日历小部件)。此应用程序中有许多
日期选择器。我不知道是哪一个导致了异常

我如何调试这个

UnhandledException: Must disconnect specified child from current parent Visual before attaching to new parent Visual.
    at System.Windows.Media.Visual.AddVisualChild(Visual child)
    at System.Windows.Documents.NonLogicalAdornerDecorator.set_Child(UIElement value)
    at System.Windows.Controls.Primitives.Popup.CreateWindow(Boolean asyncCall)
    at System.Windows.Controls.Primitives.Popup.OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
    at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
    at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
    at System.Windows.Controls.DatePicker.OnIsDropDownOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
    at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
    at System.Windows.DependencyObject.SetCurrentValueInternal(DependencyProperty dp, Object value)
    at System.Windows.Controls.DatePicker.TogglePopUp()
    at System.Windows.Controls.DatePicker.DropDownButton_Click(Object sender, RoutedEventArgs e)
    at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
    at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
    at System.Windows.Controls.Primitives.ButtonBase.OnClick()
    at System.Windows.Controls.Button.OnClick()
    at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
    at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
    at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
    at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
    at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
    at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
    at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
    at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
    at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
    at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
    at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
    at System.Windows.Input.InputManager.ProcessStagingArea()
    at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
    at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
    at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
    at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
    at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
    at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
    at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
    at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
    at System.Windows.Application.RunDispatcher(Object ignore)
    at System.Windows.Application.RunInternal(Window window)
    at System.Windows.Application.Run(Window window)
    at MyProject.src.App.Main()

有没有可能跟你有关?我对调试的最好建议是用谷歌搜索关键词(比如“wpf DatePicker.TogglePopUp exception disconnect”),看看你能找到什么。。。若这是MS控件的一个异常,那个么其他人可能以前就遇到过。除此之外,请检查您正在做的事情是否异常,例如后台线程。用户已确认他们没有切换主题。这只发生在一台生产机器上(数十台其他设备工作正常)。操作系统是Windows Server 2012 R2。我不能在我的开发机器上复制这个。我在谷歌上搜索了一下,发现的结果也无法重新解释这个问题。我也遇到了同样的问题,但一直找不到答案。你能弄明白吗?在我的例子中,我只是在App_dispatchernhandledexception中捕获了错误并吸收了它,但用户抱怨它锁定了日历,他们必须手动输入日期。我也不知道哪个datepicker控件抛出了错误,但我相信它是功能区菜单中的一个。此外,该应用程序正在Windows Server 2012 R2上通过RDP运行。我也想知道你为什么投了反对票,这是一个真正的问题,我们正在努力寻求解决办法!我还没有解决它,没有,但我们在同一条船上:Windows Server 2012 R2和DispatcherUnandledException。我们的另一个共同点是,我的用户也在运行RDP。这可能与此有关。这回答了你的问题吗?有没有可能跟你有关?我对调试的最好建议是用谷歌搜索关键词(比如“wpf DatePicker.TogglePopUp exception disconnect”),看看你能找到什么。。。若这是MS控件的一个异常,那个么其他人可能以前就遇到过。除此之外,请检查您正在做的事情是否异常,例如后台线程。用户已确认他们没有切换主题。这只发生在一台生产机器上(数十台其他设备工作正常)。操作系统是Windows Server 2012 R2。我不能在我的开发机器上复制这个。我在谷歌上搜索了一下,发现的结果也无法重新解释这个问题。我也遇到了同样的问题,但一直找不到答案。你能弄明白吗?在我的例子中,我只是在App_dispatchernhandledexception中捕获了错误并吸收了它,但用户抱怨它锁定了日历,他们必须手动输入日期。我也不知道哪个datepicker控件抛出了错误,但我相信它是功能区菜单中的一个。此外,该应用程序正在Windows Server 2012 R2上通过RDP运行。我也想知道你为什么投了反对票,这是一个真正的问题,我们正在努力寻求解决办法!我还没有解决它,没有,但我们在同一条船上:Windows Server 2012 R2和DispatcherUnandledException。我们的另一个共同点是,我的用户也在运行RDP。这可能与此有关。这回答了你的问题吗?