Hi. I'm getting an error when attempting to populate a Dataset. The details are below.
For reference, I have bound the UG to the Dataset, and am populating the dataset through a backgroundworker using a datareader using the following code:
Try myConn.Open() myReader = myCommand.ExecuteReader Do While myReader.Read If Me.BackgroundWorker1.CancellationPending Then 'Cancel the execution of this query. Debug.WriteLine("BGW Cancelled: " & Now.ToString) Exit Sub Else 'No Cancellation pending, keep filling the DataSet. Dim myRow As System.Data.DataRow = Me.DS_Tags_Tags1.Tables(0).NewRow For i As Integer = 0 To (myReader.FieldCount - 1) myRow(myReader.GetName(i).ToString) = myReader(i) Next DS_Tags_Tags1.Tables(0).Rows.Add(myRow) End If Loop Catch ex As Exception MessageBox.Show("Unable to retrieve tag details from the DataBase" & vbCrLf & vbCrLf & "Details:" & vbCrLf & ex.Message, AppName & " - Unable to Retrieve Tags", MessageBoxButtons.OK, MessageBoxIcon.Error) Finally If myConn IsNot Nothing AndAlso myConn.State = ConnectionState.Open Then myConn.Close() End If myCommand = Nothing myReader = Nothing Debug.WriteLine("DataSet Fill Ended: " & Now.ToString) End Try
I upgraded to the latest Infragistics hotfix the other week (1043 I believe), in order to resolve a similar error when refreshing the Dataset on the Ultracombos.
**********************************************************************
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.************** Exception Text **************System.IndexOutOfRangeException: Index was outside the bounds of the array. at Infragistics.Shared.SparseArray.EnsureScrollCountCalculatedHelper(NodeExtended n) at Infragistics.Shared.SparseArray.EnsureScrollCountCalculatedHelper(NodeExtended n) at Infragistics.Shared.SparseArray.EnsureScrollCountCalculatedHelper(NodeExtended n) at Infragistics.Shared.SparseArray.EnsureScrollCountCalculatedHelper(NodeExtended n) at Infragistics.Shared.SparseArray.EnsureScrollCountCalculated() at Infragistics.Shared.SparseArray.GetVisibleIndexOf(ISparseArrayMultiItem item, Boolean ignoreItemHiddenState) at Infragistics.Shared.SparseArray.GetItemAtVisibleIndexOffset(ISparseArrayMultiItem startItem, Int32 offset, ICreateItemCallback createItemCallback) at Infragistics.Win.UltraWinGrid.ScrollCountManagerSparseArray.GetItemAtVisibleIndexOffset(UltraGridRow startRow, Int32 offset) at Infragistics.Win.UltraWinGrid.RowsCollection.GetRowAtVisibleIndexOffset(UltraGridRow startAtRow, Int32 visibleIndexOffset, IncludeRowTypes includeRowTypes) at Infragistics.Win.UltraWinGrid.RowsCollection.GetNextVisibleRow(UltraGridRow row, IncludeRowTypes includeRowTypes) at Infragistics.Win.UltraWinGrid.RowsCollection.GetNextVisibleRow(UltraGridRow row) at Infragistics.Win.UltraWinGrid.ViewStyleBase.AddSiblingRows(VisibleRowFetchRowContext& context, VisibleRow parentVisibleRow, UltraGridRow firstSibling) at Infragistics.Win.UltraWinGrid.ViewStyleBase.RecreateRowList(RowScrollRegion rsr) at Infragistics.Win.UltraWinGrid.RowScrollRegion.GetMaxScrollPosition(Boolean scrollToFill) at Infragistics.Win.UltraWinGrid.RowScrollRegion.EnsureScrollRegionFilled(Boolean calledFromRegenerateVisibleRows) at Infragistics.Win.UltraWinGrid.RowScrollRegion.RegenerateVisibleRows(Boolean resetScrollInfo) at Infragistics.Win.UltraWinGrid.RowScrollRegion.WillScrollbarBeShown(ScrollbarVisibility assumeColScrollbarsVisible) 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.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UltraWinGrid.DataAreaUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UltraWinGrid.DataAreaUIElement.set_Rect(Rectangle value) at Infragistics.Win.UltraWinGrid.UltraGridUIElement.PositionChildElements() at Infragistics.Win.UIElement.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.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, 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, Size elementSize) 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, Boolean disposeEventArgs) 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)************** Loaded Assemblies **************mscorlib Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll----------------------------------------Microsoft.VisualStudio.HostingProcess.Utilities Assembly Version: 8.0.0.0 Win32 Version: 8.0.50727.42 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.HostingProcess.Utilities/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.HostingProcess.Utilities.dll----------------------------------------System.Windows.Forms Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll----------------------------------------System Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll----------------------------------------System.Drawing Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll----------------------------------------Microsoft.VisualStudio.HostingProcess.Utilities.Sync Assembly Version: 8.0.0.0 Win32 Version: 8.0.50727.42 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.HostingProcess.Utilities.Sync/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll----------------------------------------vshost Assembly Version: 8.0.0.0 Win32 Version: 8.0.50727.42 CodeBase: file:///C:/SVN/Orbit/Orbit/bin/Debug/Orbit.vshost.exe----------------------------------------ADODB Assembly Version: 7.0.3300.0 Win32 Version: 7.10.6030 CodeBase: file:///C:/WINDOWS/assembly/GAC/ADODB/7.0.3300.0__b03f5f7f11d50a3a/ADODB.dll----------------------------------------System.Data Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll----------------------------------------System.Deployment Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Deployment/2.0.0.0__b03f5f7f11d50a3a/System.Deployment.dll----------------------------------------System.Design Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Design/2.0.0.0__b03f5f7f11d50a3a/System.Design.dll----------------------------------------System.Runtime.Serialization.Formatters.Soap Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Serialization.Formatters.Soap/2.0.0.0__b03f5f7f11d50a3a/System.Runtime.Serialization.Formatters.Soap.dll----------------------------------------System.Web Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll----------------------------------------System.Xml Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll----------------------------------------Infragistics2.Excel.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Excel.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Excel.v7.3.dll----------------------------------------Infragistics2.Win.UltraWinDataSource.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.UltraWinDataSource.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.UltraWinDataSource.v7.3.dll----------------------------------------Infragistics2.Win.UltraWinGrid.ExcelExport.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.UltraWinGrid.ExcelExport.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.UltraWinGrid.ExcelExport.v7.3.dll----------------------------------------Infragistics2.Win.UltraWinTabbedMdi.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.UltraWinTabbedMdi.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.UltraWinTabbedMdi.v7.3.dll----------------------------------------Infragistics2.Shared.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Shared.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Shared.v7.3.dll----------------------------------------Infragistics2.Win.Misc.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.Misc.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.Misc.v7.3.dll----------------------------------------Infragistics2.Win.UltraWinEditors.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.UltraWinEditors.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.UltraWinEditors.v7.3.dll----------------------------------------Infragistics2.Win.UltraWinExplorerBar.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.UltraWinExplorerBar.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.UltraWinExplorerBar.v7.3.dll----------------------------------------Infragistics2.Win.UltraWinGrid.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.UltraWinGrid.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.UltraWinGrid.v7.3.dll----------------------------------------Infragistics2.Win.UltraWinStatusBar.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.UltraWinStatusBar.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.UltraWinStatusBar.v7.3.dll----------------------------------------Infragistics2.Win.UltraWinTabControl.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.UltraWinTabControl.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.UltraWinTabControl.v7.3.dll----------------------------------------Infragistics2.Win.UltraWinToolbars.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.UltraWinToolbars.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.UltraWinToolbars.v7.3.dll----------------------------------------Infragistics2.Win.v7.3 Assembly Version: 7.3.20073.1043 Win32 Version: 7.3.20073.1043 CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Infragistics2.Win.v7.3/7.3.20073.1043__7dd5c3163f2cd0cb/Infragistics2.Win.v7.3.dll----------------------------------------Microsoft.VisualBasic Assembly Version: 8.0.0.0 Win32 Version: 8.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll----------------------------------------Orbit Assembly Version: 1.0.0.0 Win32 Version: 1.0.0.0 CodeBase: file:///C:/SVN/Orbit/Orbit/bin/Debug/Orbit.EXE----------------------------------------System.Runtime.Remoting Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll----------------------------------------Infragistics.License Assembly Version: 1.0.5005.10 Win32 Version: 1.0.5005.10 CodeBase: file:///C:/WINDOWS/assembly/GAC/Infragistics.License/1.0.5005.10__7dd5c3163f2cd0cb/Infragistics.License.dll----------------------------------------System.Configuration Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll----------------------------------------Accessibility Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll----------------------------------------System.Transactions Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll----------------------------------------System.EnterpriseServices Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll----------------------------------------************** JIT Debugging **************To enable just-in-time (JIT) debugging, the .config file for thisapplication or computer (machine.config) must have thejitDebugging value set in the system.windows.forms section.The application must also be compiled with debuggingenabled.For example:<configuration> <system.windows.forms jitDebugging="true" /></configuration>When JIT debugging is enabled, any unhandled exceptionwill be sent to the JIT debugger registered on the computerrather than be handled by this dialog box.
It's hard to tell, but my guess is that this is a threading issue. It looks like you are updating your data on a background thread and you may not be properly marhsalling the data across to the UI thread. But that's only a guess.
its entirely possible that thats the case. Im fairly new to threading, so Im probably not doing it right. I suppose I could pass the datarow back to the progresschanged event.
Thinking about it, it almost seems to be that the UG is detecting the addition of a new row into the dataset, and trying to update itself with the rows before the row addition is finalised. is that possible? would that be causing an issue with it? That said, If I use a dataadapter to fill the dataset, these errors dont occurr. So maybe i need to be doing something to the dataset after adding in the to make it properly available on the main thread.
I've made a temporary hack to resolve this until i get solve the problem.
Initially, I tried to set the DataSource on the grid to nothing, and then rebind it after populating the Dataset. However, the UG seemed to lose all the layouts/column naming, etc.
Next, I tried to save the displaylayout when the form loads into a global variable, and then use the displaylayout.load method to reset it after reconnecting the dataset. However, this just did the same as resetting the datasource.
Finally, and this worked, I created a second copy of the dataset, that I dont use. I change the datasource to this new dataset when the BGW starts. This keeps all the columns and layouts intact, since its the exact same schema. Then, once the 'live Dataset is populated, I reconnect the datasource to the live dataset. This allows me to keep the column information/settings, and update the dataset without the error.
Threading is really quite complicated. So much so, that I find it nearly impossible to even discuss the subject in a forum post like this. I recommend reading the MS documentation on methods like BeginInvoke and InvokeRequired.