Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"A generic error occurred in GDI+" while using MeasureString

I have an overriden (WinForms) MemoEdit control (unfortunately I can't give you the code). If I enter more than 32000 characters, it raises an error "A generic error occurred in GDI+" I thought that there's an error (exception) in my control but then I tested on a simple WinForm application this code:

var myString = new string('G', 32001);
var g = this.CreateGraphics();
g.MeasureString(myString, Font, 1000);

and it crashes with the same exactly error Does anyone know why this happens or where is specified this constant of 32000 ? I couldn't find anything useful on Google.

like image 416
Victor George Cojocaru Avatar asked Nov 01 '22 03:11

Victor George Cojocaru


1 Answers

This seems to be a new bug which was introduced in Windows 8. I would be curious as to the behaviour in an older version of Windows:

https://connect.microsoft.com/VisualStudio/feedback/details/776722/label-control-throws-an-exception-if-its-text-is-set-to-a-very-long-string

like image 89
Frank Hileman Avatar answered Nov 11 '22 08:11

Frank Hileman