xaml - 这通常是什么意思,错误 HRESULT E_FAIL 已从对 COM 组件的调用返回。?

标签 xaml silverlight-4.0 hresult

我有一个带有 DataGrid (silverlight 4) 的特定 View 。但是我有一个项目,其中资源已与另一个项目合并(用于向后支持)。现在,在这次合并之后,每当我尝试向我的 ObservableCollection 添加一个新行对象时,我都会收到此错误...我的理论是 xaml 有问题(我可以触摸!)或者,希望是合并资源(样式和画笔)。

MS.Internal.WrappedException was unhandled by user code
  Message=Error HRESULT E_FAIL has been returned from a call to a COM component.
  StackTrace:
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.DataGrid.InsertDisplayedElement(Int32 slot, UIElement element, Boolean wasNewlyAdded, Boolean updateSlotInformation)
       at System.Windows.Controls.DataGrid.OnAddedElement_Phase1(Int32 slot, UIElement element)
       at System.Windows.Controls.DataGrid.OnInsertedElement_Phase1(Int32 slot, UIElement element, Boolean isCollapsed, Boolean isRow)
       at System.Windows.Controls.DataGrid.InsertElement(Int32 slot, UIElement element, Boolean updateVerticalScrollBarOnly, Boolean isCollapsed, Boolean isRow)
       at System.Windows.Controls.DataGrid.InsertElementAt(Int32 slot, Int32 rowIndex, Object item, DataGridRowGroupInfo groupInfo, Boolean isCollapsed)
       at System.Windows.Controls.DataGrid.InsertRowAt(Int32 rowIndex)
       at System.Windows.Controls.DataGridDataConnection.NotifyingDataSource_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Windows.Data.PagedCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       at System.Windows.Data.PagedCollectionView.ProcessAddEvent(Object addedItem, Int32 addIndex)
       at System.Windows.Data.PagedCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
       at System.Windows.Data.PagedCollectionView.<.ctor>b__0(Object sender, NotifyCollectionChangedEventArgs args)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.Add(T item)
InnerException: 
       Message=Error HRESULT E_FAIL has been returned from a call to a COM component.
       StackTrace:
            at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
            at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
            at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
            at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
       InnerException: 

最佳答案

这通常意味着您的 XAML 存在无法在设计时验证但会在运行时出现的问题。鉴于您的情况,我猜测您添加的行可能会导致 Datagrid 列模板之一以这种方式出错。

这通常是由于引用了不存在或不在 XAML 上下文中的样式或事件处理程序。根据我的经验,这在自定义控件开发中很常见。

查看我对类似问题的回答 here .

哈。

关于xaml - 这通常是什么意思,错误 HRESULT E_FAIL 已从对 COM 组件的调用返回。?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6312046/

相关文章:

silverlight - 如何在 Silverlight 中向模板化控件添加事件?

C# 多线程访问 Excel 文件

c# - 在 WPF 中显示动画 gif

c# - 更新对象后刷新 wpf 数据绑定(bind)

wpf - <i : Interaction. Behavior> 选项不适用于应用行为

windows-phone-7 - Windows Phone 7 的独立存储位置?

wpf - C++/CLI、XAML 和事件处理程序

silverlight-4.0 - 银光 : Determine parent TreeViewItem?

c++ - 在命令行上将 HRESULT 作为字符串传递

c# - HRESULT 异常 : 0x80131047