这通常意味着什么,错误HRESULT E_FAIL已从调用COM组件返回.

Alv*_*par 6 xaml hresult silverlight-4.0

我有一个DataGrid(silverlight 4)的特定视图.但我有一个资源已与另一个项目合并的项目(用于向后支持).现在,这个合并后,每当我尝试添加一个新行oject我的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: 
Run Code Online (Sandbox Code Playgroud)

ara*_*oft 20

这通常意味着您的XAML存在一个问题,该问题无法在设计时验证,但会在运行时显示.鉴于您的方案,我猜测您添加的行可能会导致其中一个Datagrid列模板以这种方式出错.

这通常是由于对样式或事件处理程序的引用不存在或不在XAML的上下文中.根据我的经验,这是Custom Control开发中常见的问题.

在此处查看我对类似问题的回答.

HTH.