We have deployed your control in several of our applications
Our users get the .net control error or what they call the "Red Cross of Death" too frequently. During busy periods this can be 2-3 times a day.
We are binding your grid to an object that inherits from BindingList
--All our updates are on the GUI thread
--We are using the ChangeNotification workaround we found on your web site, IE supress OnListChanged event when we know there are a lot of updates
This is the exception logged on one of the users PC's
Event Type: Information
Event Source: MWAM.EMS.Blotter
Event Category: None
Event ID: 0
Date: 13/12/2006
Time: 09:09:09
User: N/A
Description:
Object reference not set to an instance of an object. StrackTrace: at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.UpdateCellAppearance(GridCellInfo cell, Boolean always)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRegularRowCell(GridViewDrawArgs e, GridCellInfo ci)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRegularRow(GridViewDrawArgs e, GridDataRowInfo ri)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRow(GridViewDrawArgs e, GridRowInfo ri)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRows(GridViewDrawArgs e)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawContents(GridViewDrawArgs e)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.Draw(ViewDrawArgs ee)
at DevExpress.XtraGrid.Views.Base.BaseView.Draw(GraphicsCache e)
at DevExpress.XtraGrid.GridControl.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 DevExpress.XtraEditors.Container.EditorContainer.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)
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Event Type: Information
Event Source: MWAM.EMS.Blotter
Event Category: None
Event ID: 0
Date: 13/12/2006
Time: 09:21:52
User: N/A
Description:
The description for Event ID ( 0 ) in Source ( MWAM.EMS.Blotter ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. The following information is part of the event:
Parameter is not valid. StrackTrace: at System.Drawing.Graphics.get_PageUnit()
at DevExpress.Utils.Text.FontsCache.GetFontCacheByFont(Graphics graphics, Font font)
at DevExpress.Utils.Text.FontsCache.GetStringSize(Graphics graphics, String text, Font font, StringFormat stringFormat, Int32 maxWidth)
at DevExpress.Utils.Text.TextUtils.GetStringSize(Graphics g, String text, Font font, StringFormat stringFormat, Int32 maxWidth)
at DevExpress.Utils.Paint.XPaintMixed.CalcTextSize(Graphics g, String s, Font font, StringFormat strFormat, Int32 maxWidth)
at DevExpress.Utils.AppearanceObject.CalcTextSize(Graphics g, StringFormat sf, String s, Int32 width)
at DevExpress.Utils.AppearanceObject.CalcTextSize(Graphics g, String s, Int32 width)
at DevExpress.Utils.Drawing.HeaderObjectPainter.CalcObjectMinBounds(ObjectInfoArgs e)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcMinColumnRowHeight(Int32 headerHeight)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRectsConstants()
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRects(Rectangle bounds, Boolean partital)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.Calc(Graphics g, Rectangle bounds)
at DevExpress.XtraGrid.Views.Base.ColumnView.DoInternalLayout()
at DevExpress.XtraGrid.Views.Base.ColumnView.CalculateLayout()
at DevExpress.XtraGrid.Views.Base.BaseView.CalculateLayoutSynchronized()
at DevExpress.XtraGrid.Views.Base.BaseView.CheckViewInfo()
at DevExpress.XtraGrid.Views.Base.BaseView.Draw(GraphicsCache e)
at DevExpress.XtraGrid.GridControl.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 DevExpress.XtraEditors.Container.EditorContainer.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).
Please review the following Knowledge Base article. It should help you address the problem.
Big red X: A control becomes crossed with red lines after an exception
Thank you,
Nick
We have four different threads that modify the underlying datasource. All use code like this
if (this.InvokeRequired)
{
OrdersUpdatedHandler u = new OrdersUpdatedHandler(onOrdersUpdated);
this.BeginInvoke(u, new object[] { orders, initialRequest, status });
return;
}
We using both the Custom Draw Cell method and the Row Cell style events, both have try catch blocks, so cant raise an exception.
All our red cross events are have raised an unhandled thread exception…
This is a typical exception that precedes the other exceptions.
Application_ThreadException
The other exceptions
Event Type: Information
Event Source: MWAM.EMS.Blotter
Event Category: None
Event ID: 0
Date: 14/12/2006
Time: 08:27:11
User: N/A
Computer: LONWKS02116
Description:
Object is currently in use elsewhere. StrackTrace: at System.Drawing.Graphics.get_PageUnit()
at DevExpress.Utils.AppearanceObject.CalcDefaultTextSize(Graphics g)
at DevExpress.XtraEditors.ViewInfo.BaseControlViewInfo.CalcTextSizeCore(GraphicsCache cache, String text, Int32 maxWidth)
at DevExpress.XtraEditors.ViewInfo.BaseControlViewInfo.CalcTextSizeCore(Graphics g, String text, Int32 maxWidth)
at DevExpress.XtraEditors.ViewInfo.BaseControlViewInfo.CalcTextSize(Graphics g, Boolean useDisplayText)
at DevExpress.XtraEditors.ViewInfo.BaseEditViewInfo.CalcBestFitTextSize(Graphics g)
at DevExpress.XtraEditors.ViewInfo.BaseEditViewInfo.CalcBestFit(Graphics g)
at DevExpress.XtraEditors.ViewInfo.BaseEditViewInfo.CalcMinHeightCore(Graphics g)
at DevExpress.XtraEditors.ViewInfo.TextEditViewInfo.CalcMinHeightCore(Graphics g)
at DevExpress.XtraEditors.ViewInfo.BaseEditViewInfo.CalcMinHeight(Graphics g)
at DevExpress.XtraGrid.Views.Base.ViewInfo.BaseViewInfo.CalcMinEditorHeight(AppearanceObject[] styles)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcMinRowHeight()
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRectsConstants()
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRects(Rectangle bounds, Boolean partital)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.Calc(Graphics g, Rectangle bounds)
at DevExpress.XtraGrid.Views.Base.ColumnView.DoInternalLayout()
at DevExpress.XtraGrid.Views.Base.ColumnView.CalculateLayout()
at DevExpress.XtraGrid.Views.Base.BaseView.CalculateLayoutSynchronized()
at DevExpress.XtraGrid.Views.Base.BaseView.CheckViewInfo()
at DevExpress.XtraGrid.Views.Base.BaseView.Draw(GraphicsCache e)
at DevExpress.XtraGrid.GridControl.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 DevExpress.XtraEditors.Container.EditorContainer.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)
Thank you for the additional information. The grid's underlying data source must not be modified from another thread. Any synchronization via the BeginInvoke method does not help in this situation. Please review the following article to learn the details:
Can I avoid the ArgumentOutOfRangeException when updating the Grid's data
Thank you,
Nick
We are not modifying the grids underlying datasource from a speatate thread.
We ARE using Begin invoke, See my previous post.
All our modifications are done in methods called using BeginInvoke.
This is a serious issue for us.
What can we do to get the next level of support on this matter ?
I could show you the code using gotomypc ?
Can you provide a telephone number ?
David,
Sorry, if I expressed myself ineffectively in my previous answer. The BeginInvoke method is useless if you modify the grid's data source from a background thread. Consider the following example:
The grid starts data grouping. It has sorted data and calculated the number of rows in each group. At that moment, some rows are removed from the underlying data source. The XtraGrid completes grouping by enumerating rows in each group. Since the previously calculated row count is no longer valid, the exception is thrown.
The solution is to clone the data source object, modify it, and then reassign it to the grid control. This is described in the referenced Knowledge Base article:
Can I avoid the ArgumentOutOfRangeException when updating the Grid's data
Thank you,
Nick
WE ARE NOT MODIFYING THE UNDERLYING DATASOURCE FROM A SEPARATE THREAD…
Could you please clarify your code relation (the onOrdersUpdated method call) to the grid and the exception? What does this method and when is it called? If possible, please provide us with a test project. You may wish to send the entire project to us and we will help you debug it. In this case, we'll need step-by-step instructions to reproduce the problem.
Thank you,
Nick
I have reverse engineered the applied logic and in all cases there was 1 common factor that is the cause of errors:
The error is the introduction of "DevExpress.Utils.Text.FontsCache.GetFontCacheByFont(Graphics graphics, Font font)".
This class shares windows fonts between threads and that is STRICTLY FORBIDDEN. Windows usage of GDI resources (during paint message handling but also stuff like "DevExpress.Utils.Text.TextUtils.GetStringSize(Graphics g, String text, Font font, StringFormat stringFormat, Int32 maxWidth, Int32 maxHeight, IWordBreakProvider wordBreakProvider, Boolean& isCropped)") is restricted to the thread that has created the GDI resource.
In other words: "Only the thread that has created a font or window may use it, all other threads are not allowed to send windows paint messages to those windows". Measuring the size of a font in a window is also some type of paint action (although invisible because only the size of the painted text is returned).
Solution (only one of both should be implemented):
Thank you for the feedback, Stephan. I have created a separate ticket on your behalf to discuss this problem further: FontsCache might be sharing GDI resources between different threads.