I have an ASPX page that displays everything in its line as vertical text and returns PNG. It works great.
I have exactly one client that has encountered a problem. Every few days, the page stops working and throws a terrible GDI + "general" error.
Error: System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+. at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) at System.Drawing.Image.Save(Stream stream, ImageFormat format) ...
I do not know why the error occurs, or why it eventually goes away. I was able to download the test ASPX file to my installation, which used the same code with several options to see if I could identify the problem. I found that if I changed ImageFormat from Png to Jpeg, the error went away.
I could, apparently, change the product for rendering JPEG instead of PNG. However, I have no way of knowing if this will ultimately lead to intermittent errors, as of now.
Does anyone know what might cause such a problem? Thank you The code is below.
Refresh . The client server is the core of Windows Server 2008 R2 with IIS 7.5, and my application runs on .NET 4.0.
protected void Page_Load(object sender, EventArgs e) { byte[] image = GetImageBytes(this.Text); if (image != null) { Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "image/png"; Response.OutputStream.Write(image, 0, image.Length); } } private byte[] GetImageBytes(string text) { var font = new Font("Tahoma", 11, FontStyle.Bold, GraphicsUnit.Pixel);