RE: VersionNotFoundException by rfw68
rfw68
Wed May 16 08:37:02 CDT 2007
Hi WenYuan,
the error is:
Context: "Display"
Message: "There is no Original data to access."
Source: "System.Data"
Stack Trace:
at System.Data.DataRow.GetOriginalRecordNo()
at System.Data.DataRow.GetRecordFromVersion(DataRowVersion version)
at System.Data.DataRowView.GetColumnValue(DataColumn column)
at System.Data.DataColumnPropertyDescriptor.GetValue(Object component)
at
System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetValue(Int32
boundColumnIndex, Int32 columnIndex, Int32 rowIndex)
I tested a lot with this issue.
Well, after I increased the speed for the changes by factor 100 (that means
about 1000 changes per second) the error occured very often. Also the
following error occured:
Object reference not set to an instance of an object.
at System.Data.DataView.IsOriginalVersion(Int32 index)
at System.Data.DataRowView.GetColumnValue(DataColumn column)
at System.Data.DataColumnPropertyDescriptor.GetValue(Object component)
at
System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetValue(Int32
boundColumnIndex, Int32 columnIndex, Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.GetValue(Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.PaintWork(Graphics graphics,
Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex,
DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts
paintParts)
at System.Windows.Forms.DataGridViewRow.PaintCells(Graphics graphics,
Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex,
DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean
isLastVisibleRow, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewRow.Paint(Graphics graphics,
Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex,
DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean
isLastVisibleRow)
at System.Windows.Forms.DataGridView.PaintRows(Graphics g, Rectangle
boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.PaintGrid(Graphics g, Rectangle
gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean
singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.OnPaint(PaintEventArgs e)
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.DataGridView.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.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at MEKM3.Program.Main() in
D:\RWSD\Projekte\MEKM3\MekmMain\Program.cs:line 17
I think, changing the row values in a different thread was not a good idea.
I tried it with the same speed and BeginInvoke to change the row values in
the main thread and then it works fine!
I think, I will live with the slightly reduced performance by the 'Invoke',
except you have an idea how to make it thread save.
Sincerely,
Robert Witter