Hi
I use UltraGrid control to show data, if the data in the cell is very long,the application will randomly throw a generic error occured in gdi+, and then all the controls in my form will be a red X.
Error played only in Win 8
UltraWinGrid version :14.1.20141.2035
Could you help me?
Hi,
The big red X means that there was an exception raised during the painting of the control. Usually, the grid will show the details of the exception in addition to the X. So if you could post the call stack or a screen shot of the exception, it might help narrow down what's causing it.
Typical causes of the big red X are:
1) Threading issues - is your application using multiple threads, a background worker thread, or anything like that?
2) Images that are disposed - of you assign an image to the grid and then dispose of the image that the grid still needs, it can cause an exception.
3) Since you mention long text - how long are you talking about here? The TextBox control has a limit to how much text it will draw before it blows up. There are also limits to the amount of text you can draw in a single string using GDI or GDI+. The grid should be handling these limits and just failing to draw all of the text as opposed to crashing, but it's possible this is a case the grid is not handling.
The full stack is:EXCEPTION MESSAGE: A generic error occurred in GDI+.
EXCEPTION TYPE: System.Runtime.InteropServices.ExternalException
EXCEPTION SOURCE: System.Drawing
STACK TRACE:
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
at Infragistics.Win.DrawUtility.DrawStringHelper(Graphics gr, String text, Font font, SolidBrush brush, Rectangle bounds, StringFormat stringFormat, GdiDrawStringFlags drawStringFlags)
at Infragistics.Win.DrawUtility.DrawString(Graphics gr, String text, Font font, SolidBrush brush, RectangleF bounds, StringFormat stringFormat, GdiDrawStringFlags drawStringFlags)
at Infragistics.Win.DrawUtility.DrawStringHorizontalFlowHelper(DrawStringParameters& parameters)
at Infragistics.Win.DrawUtility.DrawStringHorizontalFlow(DrawStringParameters& parameters)
at Infragistics.Win.DrawUtility.DrawString(DrawStringParameters& parameters)
at Infragistics.Win.UIElementDrawParams.DrawStringHelper(Rectangle rectInsidePadding, String textToRender, Boolean multiline, Boolean wrapText, TextUIElementBase textElement, Size& textSize, Rectangle& textArea, Int32& charactersRendered, Int32& linesRendered, Boolean trackTextArea, Boolean trackCharactersRendered, Boolean measureOnly)
at Infragistics.Win.UIElementDrawParams.DrawStringHelper(Rectangle rectInsidePadding, String textToRender, Boolean multiline, Boolean wrapText, TextUIElementBase textElement, Size& textSize, Rectangle& textArea, Int32& charactersRendered)
at Infragistics.Win.TextUIElementBase.DrawForeground(UIElementDrawParams& drawParams)
at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams)
at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams)
at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)
at Infragistics.Win.UltraWinGrid.UltraGridUIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)
at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe)
at Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Hm, those Generic errors aren't very helpful. You say the problem happens at random? Are you able to reproduce the exception reliably in a sample application? If you run the same sample with the same text does it happen every time?
If you could post a small sample project that demonstrates the exception that we could run and Debug, I'm sure we could figure out what's going on there.
I posted a sample project in first message.
Hi Kostia,
Sorry, I didn't see your sample there. I ran it just now on my Windows 7 machine and it works fine. But on Windows 8, I get the same exception. This is really a DotNet framework issue and not specific to the WinGrid or Infragistics controls. It's blowing up when we call DrawString on the graphics object. So I'm certain you would have similar problems trying to display a string like this using the inbox Label or TextBox control, as well.
But like I said, the grid probably shouldn't be crashing your app. We can easily put in a check to just limit the size of the string we draw. So I'm going to ask Infragistics Developer Support to write this up as a bug so we can prevent the exception in a future service release.
Rifiuto di rіnnovo !!!
==============================
this string always generates red X Maybe there are hidden Hex characters
We have also just had this issue (on Server 2012) with a very long string in a Grid.
Good job finding the issue :-)
Adam
Hello Kostia,
Our developers have determined that this is not an issue with our controls. The attached sample does not use any of our controls but still reproduces the issue.
You should re-open the following thread and provide the attached sample project.
http://social.msdn.microsoft.com/Forums/vstudio/en-US/740aa9a5-5290-4041-a343-3785fa1e6608/systemruntimeinteropservicesexternalexception-a-generic-error-occurred-in-gdi-systemdrawing?forum=csharpgeneral
Please let me know if you have any other questions about this.
I have created support case CAS-141507-N0Z1M6 to track this issue and I have submitted it to our developers for them to research. You can view this case by clicking "Account" in the upper-right corner of this page and then clicking "Support Activity" on the left side of the page that loads.
Okay. Thanks!