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

Unhandled Exception on grid

please find attached the screan shot.When this exception occures , there is a red cross mark on the grid.This exception occures only on one machine and we had just installed the latest syncfusion on it. allinfo_error_9229.zip

10 Replies

AD Administrator Syncfusion Team August 24, 2005 07:43 AM UTC

All the red X suggests is that an error occurred during painting. Are you using multiple threads? If so, are you protecting all calls into the grid with a grid.InvokedRequired check to make sure you only interact with the grid on the thread that created it. Also, if you are using grid.BeginInvoke (as opposed to grid.Invoke), are you locking the data in the grid so that two invocation paths are not trying to access the access data that was modified by the other path (ie, one path deletes a row while the otherpath is trying to paint the row). In this case, you might try changing grid.BeginInvoke to grid.Invoe to see if the problem goes away. You might try running the application in debug with your debugger set to break on exception. This may pick up the original exception that triggerred the drawing exception that shows the red X. It is this original exception that has to be tracked down.


MP Majesh Peedikakandy August 24, 2005 09:00 AM UTC

but , this exception is seen only on one machine and we are not able to simulate it on any other machines. We are indeed using threading ,but not using grid.InvokedRequired and it still works fine on all other machines. >All the red X suggests is that an error occurred during painting. > >Are you using multiple threads? > >If so, are you protecting all calls into the grid with a grid.InvokedRequired check to make sure you only interact with the grid on the thread that created it. > >Also, if you are using grid.BeginInvoke (as opposed to grid.Invoke), are you locking the data in the grid so that two invocation paths are not trying to access the access data that was modified by the other path (ie, one path deletes a row while the otherpath is trying to paint the row). In this case, you might try changing grid.BeginInvoke to grid.Invoe to see if the problem goes away. > >You might try running the application in debug with your debugger set to break on exception. This may pick up the original exception that triggerred the drawing exception that shows the red X. It is this original exception that has to be tracked down.


AD Administrator Syncfusion Team August 24, 2005 09:35 AM UTC

Threading issues are notoriously hard to find/correct. This is one reason consistently using multithreading programming techniques, such as InvokeRequired checks for Windows Forms controls, are important. Your application can run OK for a while and all of a sudden start choking. You should test running your threading applications on a dual processor systems. This usually immediately brings forth such problems even if the same code works on other systems.


MP Majesh Peedikakandy August 24, 2005 10:13 AM UTC

So,can u tell me how exactly the grid.InvokeRequired or any other techniques can be used to prevent this problem.A code snippet or example or any article regarding this would be of great help. >Threading issues are notoriously hard to find/correct. This is one reason consistently using multithreading programming techniques, such as InvokeRequired checks for Windows Forms controls, are important. Your application can run OK for a while and all of a sudden start choking. > >You should test running your threading applications on a dual processor systems. This usually immediately brings forth such problems even if the same code works on other systems.


AD Administrator Syncfusion Team August 24, 2005 11:34 AM UTC

Here is a link to a KB. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=78 The sample link in that KB is broken. Try this link to get the sample. http://www.syncfusion.com/support/kb/grid/Files/Thread_Sample.zip


KT Krishnan Thodla August 24, 2005 04:32 PM UTC

Hi, I got the original exception trace for this below: As Majesh mentions, it happens only on one machine. ''Capgroup.IMSFI.Awb.Main.exe'': Loaded ''c:\data\awb\awbapp\awbmain\bin\debugziplib.dll'', No symbols loaded. System.ArgumentException: Value does not fall within the expected range. at Syncfusion.Windows.Forms.Grid.GridRangeInfo..ctor(Int32 top, Int32 left, Int32 bottom, Int32 right) at Syncfusion.Windows.Forms.Grid.GridRangeInfo.InternalCells(Int32 top, Int32 left, Int32 bottom, Int32 right) at Syncfusion.Windows.Forms.Grid.GridViewLayout.Initialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.DemandInitialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.IsRangeVisible(GridRangeInfo range) at Syncfusion.Windows.Forms.Grid.GridControlBase.IsVisibleCell(Int32 rowIndex, Int32 colIndex) at Syncfusion.Windows.Forms.Grid.GridControlBase.InvalidateRange(GridRangeInfo range, GridRangeOptions options) at Syncfusion.Windows.Forms.Grid.GridControlBase.ModelCellsChanged(Object sender, GridCellsChangedEventArgs e) at Syncfusion.Windows.Forms.Grid.GridCellsChangedEventHandler.Invoke(Object sender, GridCellsChangedEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModel.OnCellsChanged(GridCellsChangedEventArgs e) catched at Syncfusion.Windows.Forms.Grid.GridModel.OnCellsChanged(GridCellsChangedEventArgs e) in :line 0 System.ArgumentException: Value does not fall within the expected range. at Syncfusion.Windows.Forms.Grid.GridRangeInfo..ctor(Int32 top, Int32 left, Int32 bottom, Int32 right) at Syncfusion.Windows.Forms.Grid.GridRangeInfo.InternalCells(Int32 top, Int32 left, Int32 bottom, Int32 right) at Syncfusion.Windows.Forms.Grid.GridViewLayout.Initialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.DemandInitialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.get_VisibleRows() at Syncfusion.Windows.Forms.Grid.GridPaint.DrawClientRowCol(Int32 topRow, Int32 leftCol, Int32 bottomRow, Int32 rightCol, Graphics g, Rectangle rectClip) catched at Syncfusion.Windows.Forms.Grid.GridPaint.DrawClientRowCol(Int32 topRow, Int32 leftCol, Int32 bottomRow, Int32 rightCol, Graphics g, Rectangle rectClip) in :line 0 System.NullReferenceException: Object reference not set to an instance of an object. at Syncfusion.Windows.Forms.Grid.DrawStruct.Dispose(GridControlBase grid) at Syncfusion.Windows.Forms.Grid.GridPaint.DrawClientRowCol(Int32 topRow, Int32 leftCol, Int32 bottomRow, Int32 rightCol, Graphics g, Rectangle rectClip) at Syncfusion.Windows.Forms.Grid.GridControlBase.OnDrawClientRowCol(Int32 topRow, Int32 leftCol, Int32 bottomRow, Int32 rightCol, Graphics g, Rectangle rectClip) at Syncfusion.Windows.Forms.Grid.GridPaint.DrawGrid(Graphics g, Boolean shouldClip, Rectangle rectClip) at Syncfusion.Windows.Forms.Grid.GridControlBase.OnPaint(PaintEventArgs pe) catched at Syncfusion.Windows.Forms.Grid.GridControlBase.OnPaint(PaintEventArgs pe) in :line 0


AD Administrator Syncfusion Team August 24, 2005 05:05 PM UTC

I still think this is a threading issue. One way you can try to test for this is to derive the grid and override OnCellsChanged which is a method that is hit in the call stack you. In the override test to see if you are on the proper thread.
public class MyGridControl : GridControl
{
	protected override void OnCellsChanged(GridCellsChangedEventArgs e)
	{
		if(this.InvokeRequired)
		{
			throw new Exception("Wrong Thread.");
		}
		base.OnCellsChanged (e);
	}
}


AD Administrator Syncfusion Team August 24, 2005 11:05 PM UTC

What version of our grid are you running? Version 3.3RC has some fixes in it for handling a problem with checkboxes not being thread safe, and one other threading issue. In our direct trac incident database, this "Value does not fall within the expected range" error has been reported 17 times. Without exception, threading was involved in those projects. Using grid.InvokeRequired checks has been the solution in most of these cases. In other projects, the threading was removed as it did not serve a useful purpose.


MP Majesh Peedikakandy August 26, 2005 06:03 AM UTC

thanx a lot clay, it works fine now. but, will this affect the performance gain that we get through threading ??


AD Administrator Syncfusion Team August 26, 2005 06:22 AM UTC

It may. But if you try using asynch invocation (BeginInvoke instead of Invoke), then you will have to do the extra work of making sure no thread is changing data that might be in use by another thread though some lock technique. Otherwise, you will still have threading issues. This is a requirement on using Windows Forms Controls in multiple threads, they as not thread safe.

Loader.
Live Chat Icon For mobile
Up arrow icon