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.
Unfortunately, activation email could not send to your email. Please try again.

Unhandled Exception on grid

Thread ID:

Created:

Updated:

Platform:

Replies:

33668 Aug 24,2005 02:12 AM Aug 26,2005 02:22 AM Windows Forms 10
loading
Tags: GridControl
Majesh Peedikakandy
Asked On August 24, 2005 02:12 AM

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

Administrator [Syncfusion]
Replied On August 24, 2005 03:43 AM

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.

Majesh Peedikakandy
Replied On August 24, 2005 05:00 AM

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.

Administrator [Syncfusion]
Replied On August 24, 2005 05:35 AM

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.

Majesh Peedikakandy
Replied On August 24, 2005 06:13 AM

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.

Administrator [Syncfusion]
Replied On August 24, 2005 07:34 AM

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

Krishnan Thodla
Replied On August 24, 2005 12:32 PM

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\debug\nziplib.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

Administrator [Syncfusion]
Replied On August 24, 2005 01:05 PM

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);
	}
}

Administrator [Syncfusion]
Replied On August 24, 2005 07:05 PM

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.

Majesh Peedikakandy
Replied On August 26, 2005 02:03 AM

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

Administrator [Syncfusion]
Replied On August 26, 2005 02:22 AM

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;