What does this usually mean, Error HRESULT E_FAIL has been returned from a call to a COM component.?
Asked Answered
H

1

6

I have a particular view with a DataGrid (silverlight 4). But i have a project where resources have been merged with another project (for backward support). Now, after this merge, i am getting this error whenever i try to add a new row oject to my ObservableCollection.... my theory is that it is something wrong with the xaml (which i can touch!) or, hopefully, the merged resources (styles & brushes).

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: 
Horick answered 10/6, 2011 at 21:3 Comment(1)
Sounds to be like you've found a genuine bug. Try creating a simple as possible project that reproduces the problem. Use Microsoft's Connect site to report it. You might also consider repeating this question on Microsofts own silverlight forums, the MSFT support chappies are more active there.Strobe
F
21

This usually means that there is a problem with your XAML that couldn't be validated at design time but would manifest in runtime. Given your scenario I'm guessing the row you're adding may cause one of the Datagrid column templates to error in this manner.

This usually is due to a reference to a style or an event handler that does not exist or is not within the context of the XAML. In my experience this is a common occurence in Custom Control development.

See my answer to a similar question here.

HTH.

Fabled answered 15/3, 2012 at 3:38 Comment(2)
Link no longer works, perhaps theres another way to link to it?Conde
social.msdn.microsoft.com/Forums/en-US/…Fabled

© 2022 - 2024 — McMap. All rights reserved.