We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Runtime exception on a multi processor machine

Hi, I have a DataBoundGrid Control that is bound to a data view. The data view is updated around 100-150 time a second on a seperate thread. The app runs fine on a single CPU machine but when I run it on a multi (4) cpu machine, it throws runtime exception: System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.DataView.get_RowViewCache() at System.Data.DataView.GetElement(Int32 index) at System.Data.DataView.System.Collections.IList.get_Item(Int32 recordIndex) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.QueryCellInfo(GridQueryCellInfoEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.Syncfusion.Windows.Forms.Grid.IGridModelDataProvider.QueryCellInfo(GridQueryCellInfoEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModel.GetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style) at Syncfusion.Windows.Forms.Grid.GridModel.Syncfusion.Windows.Forms.Grid.IGridVolatileDataContainer.GetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style) at Syncfusion.Windows.Forms.Grid.GridVolatileData.get_Item(Int32 rowIndex, Int32 colIndex) at Syncfusion.Windows.Forms.Grid.GridModel.get_Item(Int32 rowIndex, Int32 colIndex) at Syncfusion.Windows.Forms.Grid.GridControlBase.GetViewStyleInfo(Int32 rowIndex, Int32 colIndex, Boolean forceQueryCellInfo) at Syncfusion.Windows.Forms.Grid.GridControlBase.GetViewStyleInfo(Int32 rowIndex, Int32 colIndex) at Syncfusion.Windows.Forms.Grid.GridControlBase.GetCellRenderer(Int32 rowIndex, Int32 colIndex) at Syncfusion.Windows.Forms.Grid.SelectCellsHitTestInfo..ctor(GridControlBase grid, MouseEventArgs e, IMouseController controller) at Syncfusion.Windows.Forms.Grid.GridSelectCellsMouseController.HitTest(MouseEventArgs e, IMouseController controller) at Syncfusion.Windows.Forms.MouseControllerDispatcher.HitTest(Point point, MouseButtons mouseButton, Int32 clicks, IMouseController& controller) at Syncfusion.Windows.Forms.MouseControllerDispatcher.ProcessMouseMove(MouseEventArgs e) at Syncfusion.Windows.Forms.ScrollControllMouseControllerDispatcher.ScrollControlMouseMoveHandled(Object sender, MouseEventArgs e) at Syncfusion.Windows.Forms.ScrollControl.OnScrollControlHandledMouseMove(MouseEventArgs e) at Syncfusion.Windows.Forms.ScrollControl.OnMouseMove(MouseEventArgs e) at Syncfusion.Windows.Forms.Grid.GridControlBase.OnMouseMove(MouseEventArgs e) at Syncfusion.Windows.Forms.Grid.GridControlBaseImp.OnMouseMove(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseMove(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg) at Syncfusion.Windows.Forms.Grid.GridControlBase.WndProc(Message& msg) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) I am attaching the relevant code. Any help is appreciated. Thanks, Lalit StrategyForm_7676.zip

10 Replies

AD Administrator Syncfusion Team December 6, 2004 05:41 PM UTC

Make sure you are using 2.1.0.9 or later. Are you trying to access the grid on some thread other than the thread that created the grid? If so, you will see these kinds of exceptions. Here is a KB article discussing this problem for a GridControl. http://64.78.18.34/Support/article.aspx?id=572


AD Administrator Syncfusion Team December 6, 2004 06:27 PM UTC

I am using 2.1.0.9. I am not accessing the grid on any other thread except on the thread that created it. I am using multiple thread just to update the DataSet and since I bind the grid to the DataView, the row updates itself. Am I doing anything wrong? The grid updates properly until I move the mouse over it and it behaves correctly on single cpu machine, it throws exception on multi cpu machines. Is there a way I can cancel MouseMoveEvent or any other event in the stack trace. I am wondering if that would help. Thanks a lot, Lalit


AD Administrator Syncfusion Team December 6, 2004 08:40 PM UTC

I think this is a threading issue. The symptom you mentioned is a common one. To check for this, you can add a handler for the grid.Model.QueryCellInfo event, and in your handler check for grid.InvokeRequired to see the thread is correct. Private Sub model_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs) If Me.GridDataBoundGrid1.InvokeRequired Then MessageBox.Show("Wrong Thread") End If End Sub


AD Administrator Syncfusion Team December 7, 2004 01:58 PM UTC

Hi Clay, I tried that. It doesn''t help. I checked it twice to make sure that the execution goes to that method but it doesn''t go inside the if block. Anyways, .NET CLR throws an exception, other than the null reference exception, when I try to access the grid on the thread that didn''t create it. Any other suggestion that might help. Thanks, Lalit


AD Administrator Syncfusion Team December 7, 2004 03:38 PM UTC

If you can prepare a sample project that shows this problem, we can try to debug it here. You can create a direct trac support incident to upload it.


AD Administrator Syncfusion Team December 8, 2004 11:15 AM UTC

Clay, Here is the full test project. Lalit


AD Administrator Syncfusion Team December 8, 2004 11:17 AM UTC

It didn''t work last time. I am uploading the project once again. Thanks, Lalit


AD Administrator Syncfusion Team December 8, 2004 12:11 PM UTC

I got your sample. Thank you. I do not think this particular problem is nescessarily related to our GridDataBoundGrid. In your sample, if you replace our grid with a Windows Forms DataGrid, you will see the same type exception thrown in FormLoad when you are setting the DataSource. Just a guess. Is your worker thread immediately updating this datatable as it is trying to be set as the datasource to the datagrid? What might be happening grid is trying to respond to an update before the binding code has completed.


AD Administrator Syncfusion Team December 8, 2004 12:34 PM UTC

Since you are using grid.DataSource = dt.DefaultView, it may be that the currencymanager for this DataView was created on the thread that created the DataTable, and this is what is causing the problem. So, in your code I changed that line to read: grid.DataSource = new DataView(dt); to be sure the CurrencyManager would be set on this UI thread. That seemed to fix this problem with our GridDataBoundGrid in your sample. It did not completely fix the problem in the DataGrid. The program gets further with the DataGrid, but locks up when it starts to draw. Our grid has special code to make sure the drawing gets done on the proper thread. The DataGrid does not have this code.


AD Administrator Syncfusion Team December 8, 2004 04:53 PM UTC

Yeah, You are right. I will try to reproduce the same error and let you know. Thanks for your help. Lalit

Loader.
Live Chat Icon For mobile
Up arrow icon