WPF System.ComponentModel.Win32Exception(0x80004005):无效的窗口句柄

9

我在WPF上遇到了以下错误。

我在窗口上使用MVVM数据绑定到DataContext + CollectionViewSources。

由于ViewModel和View中的代码太多,无法贴出,请问应该从哪里查找此错误,因为没有行号显示。

该窗口使用带有转换器的WPF数据绑定,并且其中还有一些Telerik控件。

这是在调用后发生的错误。

TabItemSelectionEditor.UpdateLayout() 

TabItemSelectionEditor是一个System.Windows.Control.TabItem

System.ComponentModel.Win32Exception (0x80004005): 无效的窗口句柄

at MS.Win32.UnsafeNativeMethods.GetWindowText(HandleRef hWnd, StringBuilder lpString, Int32 nMaxCount)

at System.Windows.Automation.Peers.WindowAutomationPeer.GetNameCore()

at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()

at System.Windows.ContextLayoutManager.fireAutomationEvents()

at System.Windows.ContextLayoutManager.UpdateLayout()

at System.Windows.UIElement.UpdateLayout()

at System.Windows.Controls.VirtualizingStackPanel.<>c_DisplayClassb.b_7()

at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

内部异常为空!


有什么其他信息吗?实际上,甚至没有太多可以猜测的。那似乎是处理异常的堆栈 - 而不是导致异常的堆栈。有内部异常吗?那个内部异常是什么? - Peter Ritchie
我刚刚添加了一些更多的细节。 - DermFrench
2
我看到了一个很大的问题,但是不知道它来自哪里:类型:System.ComponentModel.Win32Exception 信息:当文件已经存在时无法创建文件 堆栈跟踪: 在MS.Win32.UnsafeNativeMethods.GetWindowText(HandleRef hWnd, StringBuilder lpString, Int32 nMaxCount) 在System.Windows.Automation.Peers.WindowAutomationPeer.GetNameCore() ... 在MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) - Volker von Einem
我看到了和@Volker von Einem完全相同的异常。我不知道为什么。有人有线索吗? - lot
1个回答

0
你的代码中没有一个名为 DisplayClass 的方法吗?
我还可以看到涉及到一个 VirtualizingStackPanel,并且当它在其子元素上调用 UIElement.UpdateLayout() 方法时出现了错误。
这大概是我从这个错误中能够解决的全部问题了,如果没有更多信息,我就无法再提供更多帮助了。

我在我的ViewModel上有一个.Show()方法,用于创建视图并显示它。这是你所指的DisplayClass方法吗? - DermFrench
不是的。这只是一个猜测,但你的意思是说在应用程序中没有名为“DisplayClass”的类、方法或自定义对象?这是因为错误信息中提到了“DisplayClass”这一行……这不是“VirtualizingStackPanel”类的方法,所以我认为它来自你的代码。 - Sheridan
也许那是在Telerik的代码里?因为我在Tab Item里使用了一些Telerik的东西。 - DermFrench
可能是来自Telerik...也许你应该联系他们? - Sheridan
嘿,我移除了Telerik并切换到内置的.NET WPF TabControl,但问题依旧存在。 - DermFrench

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接