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...
Thank you. It was a threading issue. I removed threads and it worked fine.
I dont use threads in my application, but using presenter pattern, which might use seperate thread. and wont be able to change the pattern though and now I am also getting the same error in my dev machine too. And all it happens only after the latest update. Really appreciate if we could get a fix for this. Thanks...
What's a "presenter pattern?" Are you using WPF or Windows forms?
If you are using the latest version and not using threading, then either this is a bug in the control or lse something in your code is causing it.
Can you post a small sample project demonstrating the exception so I can take a look? Without being able to reproduce the issue, I'm afraid I can't do much except make some pretty wild guesses.
Thanks for the reply. I am using WinForms on Dot Net Framework 4.0. Using Model View Presenter Pattern. Grid Control is in Win Form and all the code that handles the events are in the seperate Presenter Class. Usually I always check my code for bugs. But this one I am confused by the exception message. I am pasting the error stack. i will also email the sample project.
If you can post a sample project so we can duplicate the exception, we can certainly look into it.
My guess is that this was a bug in the 9.2 version of the controls. The version you are using was the last service release, so it's possible that this bug went unnoticed until after the 9.2 version was retired.
Are you using formulas in for your summaries (or anything else)? Or are you just using the built-in summaries?
If you are using formulas, then you might be able to work around this by setting the FormulaRowSourceIndex to something other than VisibleIndex.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridOverride ov = layout.Override; ov.FormulaRowIndexSource = FormulaRowIndexSource.RowIndex; // or //ov.FormulaRowIndexSource = FormulaRowIndexSource.ListIndex; }
If that doesn't work, I recommend that you try downloading a trial version of NetAdvantage 11.2 and see if the problem is fixed in the latest version.
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. :-)
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.
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 **************
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