Silverlight ChildWindow:ChildWindow.Show() 上的 HRESULT E_FAIL
我的 ChildWindow 控件有一些问题,我创建了一个错误窗口控件,该控件在 app.xaml.cs 中捕获未处理的异常后显示。问题是当我尝试显示错误窗口时,有时它工作正常,但有时我会得到这个令人讨厌的异常:
消息: 对 COM 组件的调用返回了错误 HRESULT E_FAIL。
堆栈跟踪: 在MS.Internal.XcpImports.CheckHResult(UInt32小时)在MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj,DependencyProperty属性,布尔b)在System.Windows.DependencyObject.SetValue(DependencyProperty属性,布尔b)在System.Windows。 Controls.Primitives.Popup.set_IsOpen(布尔值)位于 System.Windows.Controls.ChildWindow.Show() 位于 FrontEnd.SL.Util.GuiLogger.ShowErrorWindow(ErrorDetails 详细信息,ErrorSeverity 严重性)
您看到的跟踪位于 ChildWindow 的 Show() 方法内。
换句话说,我的代码是:
ErrorWindow errorWin= new ErrorWindow();
errorWin.Show();
其中错误窗口:子窗口
非常感谢任何帮助..
I have some problems with ChildWindow control, I have created an error window control that is shown after unhandled exception is caught in app.xaml.cs. The problem is when I try to show the error window, sometimes it works fine, but sometimes I get this nasty exception:
Message:
Error HRESULT E_FAIL has been returned from a call to a COM component.
Stack Trace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr) at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, Boolean b) at System.Windows.DependencyObject.SetValue(DependencyProperty property, Boolean b) at System.Windows.Controls.Primitives.Popup.set_IsOpen(Boolean value) at System.Windows.Controls.ChildWindow.Show() at FrontEnd.SL.Util.GuiLogger.ShowErrorWindow(ErrorDetails details, ErrorSeverity severity)
the trace you see is inside the Show() method of the ChildWindow.
In another words, my code is:
ErrorWindow errorWin= new ErrorWindow();
errorWin.Show();
where ErrorWindow:ChildWindow
any help is greatly appreciated..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我看来,使用 ChildWindow 控件很容易出现一些问题。如果现有 VisualTree 由于异常而处于不一致/损坏状态,会发生什么情况?
在应用程序范围内“处理”未处理异常的最佳机会是完全替换 VisualRoot 持有的现有对象。
It seems to me that the use of a ChildWindow control is going to be prone to some problems. What happens if the incumbent VisualTree is in an inconsistent/broken state as result of the exception?
The best chance you have to "handling" an unhandled exception within the bounds of the application would be to completely replace the existing object held by the VisualRoot.
如果加载子窗口内容时出现问题,也可能会发生这种情况。就我而言,我在用户控件的代码隐藏及其 xaml 中指定了不同的命名空间,这导致了这个神秘的错误。
This can also happen if there is a problem loading the content of the childwindow. In my case I had specified different namespaces in a usercontrol's code-behind and its xaml, which caused this cryptic error.