"General error occurred in GDI +" when using MeasureString

I have control over MemoEdit (WinForms) (unfortunately, I can not give you the code). If I enter more than 32,000 characters, this will lead to the error "General error that occurred in GDI +" I thought that there was an error (exception) in my control, but then I checked this code on a simple WinForm application:

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

and it crashes with the same error Does anyone know why this is happening or where this constant 32000 is indicated? I did not find anything useful on Google.

+4
source share
2 answers

This seems to be a new bug that was introduced in Windows 8. I would be interested to know about the behavior in the old 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

+2

, Int32.Max(, ).

, , , (. MSDN-Link: For bidirectional languages, such as Arabic, the string length must not exceed 2046 characters).

, 31999- /.

0

All Articles