I have Infragistics 9.2.20092.2119 ( even after I downloaded the latest service release yesterday ) I am continously getting this error. This form has a Ultragrid with row summary
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Infragistics.Shared.SparseArray.ValidateIndex(Int32 index)
at Infragistics.Shared.SparseArray.GetItem(Int32 index, ICreateItemCallback createItemCallback)
at Infragistics.Win.UltraWinGrid.RowsCollection.InternalTraverseRowsHelper(UltraGridBand band, IRowCallback rowCallback, IRowsCollectionCallback rowsCollectionCallback, Boolean recursive, Boolean includeTemplateAddRows)
at Infragistics.Win.UltraWinGrid.RowsCollection.InternalTraverseRowsHelper(UltraGridBand band, IRowCallback rowCallback, Boolean recursive)
at Infragistics.Win.UltraWinGrid.SummaryValue.CalculateSummaryValue(RowsCollection rows, SummarySettings summarySettings)
at Infragistics.Win.UltraWinGrid.SummaryValue.CalculateSummaryValue()
at Infragistics.Win.UltraWinGrid.SummaryValue.get_Value()
at Infragistics.Win.UltraWinGrid.SummaryValue.get_SummaryText()
at Infragistics.Win.UltraWinGrid.SummaryValueUIElement.PositionChildElements()
at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
at Infragistics.Win.UltraWinGrid.RowColRegionIntersectionUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
at Infragistics.Win.UltraWinGrid.DataAreaUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
at Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)
at Infragistics.Win.UltraWinGrid.UltraGridUIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)
at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe)
at Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The second error I get is I have a form with Ultragrid and UltraGridExcelExporter
and the error is
System.ArgumentException: Parameter is not valid. at System.Drawing.Graphics.GetHdc() at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter..ctor() at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter..ctor(IContainer container) at Pearlpos.Forms.ItemListView.InitializeComponent() at Pearlpos.Forms.ItemListView..ctor()
System.ArgumentException: Parameter is not valid.
at System.Drawing.Graphics.GetHdc()
at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter..ctor()
at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter..ctor(IContainer container)
at Pearlpos.Forms.ItemListView.InitializeComponent()
at Pearlpos.Forms.ItemListView..ctor()
Hi,
Is your application using multiple threads? My best guess is that this is a threading issue.
If you are not using threading at all, then it's possible this was a bug in that old version of the controls. Can you post a small sample project demonstrating either of these exceptions? If so, I'd be happy to try it out in the latest version and verify that the problem has been fixed - or if not, look into fixing it.
Sure, I will post a sample project. But this error doesnt happen in dev machine, it happens only in few customer machines...
Hi.. I have been having this problem for a while now too. I'm interested in why using threads would be an issue and if there is a way to still use threading and not get this error.
We run some checks on the number of items in several areas to update the toolbar items with the numbers (we have not yet implemented the badges yet, but plan to) and in the worker completed event we update the toolbar items with the new settings.
We also use the tabbed mdi control with the toolbar manager.
Any suggestions on where to look or what to look for would be greatly appreciated.
Here's the stack trace of the error I am getting
at System.Drawing.Image.get_FrameDimensionsList() at System.Drawing.ImageAnimator.CanAnimate(Image image) at Infragistics.Win.AnimatedImageManager.AnimateHelper(Image image, UIElement owningElement, Boolean isBackgroundImage) at Infragistics.Win.ImageUIElementBase.DrawImage(UIElementDrawParams& drawParams) at Infragistics.Win.ImageAndTextUIElement.ImageAndTextDependentImageUIElement.DrawImage(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe) at Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea.OnPaint(PaintEventArgs pe) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
DeclaringMethod = 'DirectCast(DirectCast(e.Exception._exceptionMethod, System.Reflection.RuntimeMethodInfo).DeclaringType, System.RuntimeType).DeclaringMethod' threw an exception of type 'System.InvalidOperationException'
It's nearly impossible to safely use a bound control like the WinGrid in a multi-threaded environment. There's a long and detailed discussion of why that's the case here.
The error message you are getting here may not be related to threading, though. There's a known bug in that area. So you should get the latest service release and that will probably fix it.
How to get the latest service release - Windows Forms - Service Releases
Mike,
I've similar issue with UltraWinGrid that I am binding to BindingList<MyClass>. It was working all fine until recently I added a couple of fields (Enum and string fields) to my class that I am updating in separate thread spawned by Task(TPL). I am not adding new items in DataSource itself but i am just changing data in BindingList and Ultragrid throws following error once out of 4-5 times I update the object. The dll version for UltraWinGrid is 13.1.20131.2124.
Also, I've changed my code as following recently to update the row display in case the object is modified in seperate thread.
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { try { this.Grid.SuspendRowSynchronization(); FileWatchConfiguration fwc = e.Row.ListObject as FileWatchConfiguration; if (!bInitializing) { if (fwc != null) { SetStatusCellBackColor(fwc.Status, e.Row.Cells["Status"]); this.Grid.DisplayLayout.PerformAutoResizeColumns(false, PerformAutoSizeType.AllRowsInBand); } } } finally { this.Grid.ResumeRowSynchronization(); } }
Here is the exception I am seeing. Is there anything I can do to prevent the error? I am thinking about adding an unbound column and changing its content as part of ultraGrid1_InitializeRow. But, i don't want to add something silly like that if there is a better way to address it.
************** Exception Text **************
at System.Array.Clear(Array array, Int32 index, Int32 length)
at System.Collections.Generic.Dictionary`2.Clear()
at Infragistics.Win.UltraWinGrid.UltraGridLayout.EndCaching()
at Infragistics.Win.UltraWinGrid.RowScrollRegion.RegenerateVisibleRows(Boolean resetScrollInfo)
at Infragistics.Win.UltraWinGrid.RowScrollRegion.WillScrollbarBeShown(ScrollbarVisibility assumeColScrollbarsVisible)
at Infragistics.Win.UltraWinGrid.ViewStyleBase.FitColumnsToWidth()
at Infragistics.Win.UltraWinGrid.BandsCollection.CalculateBandMetrics(Int32 pass)
at Infragistics.Win.UltraWinGrid.BandsCollection.CalculateBandMetrics()
at Infragistics.Win.UltraWinGrid.ColScrollRegionsCollection.InitializeMetricsHelper()
at Infragistics.Win.UltraWinGrid.ColScrollRegionsCollection.InitializeMetrics()
at Infragistics.Win.UltraWinGrid.RowScrollRegion.PositionScrollbar(Boolean resetScrollInfo)
at Infragistics.Win.UltraWinGrid.ScrollRegionBase.SetOriginAndExtent(Int32 origin, Int32 extent)
at Infragistics.Win.UltraWinGrid.RowScrollRegion.SetOriginAndExtent(Int32 origin, Int32 extent)
at Infragistics.Win.UltraWinGrid.DataAreaUIElement.ResizeRowScrollRegions()
at Infragistics.Win.UltraWinGrid.DataAreaUIElement.PositionChildElements()
at Infragistics.Win.UltraWinGrid.DataAreaUIElement.set_Rect(Rectangle value)
at Infragistics.Win.UltraWinGrid.UltraGridUIElement.PositionChildElements()
************** Loaded Assemblies **************
Multithreading and databinding do not mix well. You cannot modify or even examine the data in the grid's DataSource (or even a BindingSource) on anything other than the UI thread safely. There's no way to do that, because you cannot properly marshal that communication across the threads since you are not in control of that communication.
That's one of the hallmarks of a threading issue - it happens intermittently.
Thanks for the info Mike. I'll try to invoke the property change on main thread. I am not getting this exception frequently so i won't know if it fixed my issue for sure. :-)