A generic error occurred in gdi+

1

November 19, 2008 by Alistair Deneys

I had the above error the other day when using a new install of Sitecore. At first the error doesn’t seem to reveal much, and it quite … generic 🙂 . This was happening when I was trying to create a new rendering through the developer centre in the Sitecore desktop. The full error was:

gdi error

And the error is logged in the log file as well.

Exception: System.Runtime.InteropServices.ExternalException
Message: A generic error occurred in GDI+.
Source: System.Drawing
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
  EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at Sitecore.Resources.FileIcon.GetIcon(String extension, Int32 width,
  Int32 height, Color background)
at Sitecore.Resources.FileIcon.GetIcon(String extension, ImageDimension dimension)
at Sitecore.Resources.FileIcon.GetFileIcon(String filename,
  ImageDimension dimension)
at Sitecore.Data.DataProviders.FileSystemDataProvider.GetItemFields
  (ItemDefinition itemDefinition, VersionUri version, CallContext context)...

For those that don’t know, GDI+ is basically the .net drawing subsystem. It is a hook into the Windows GDI subsystem. Normally when you start getting errors in GDI+ it indicates a low level problem, or some bad parameters or something.

And if we start to read the stack trace above we can see that an Image was being saved when the error occurred. But all I was doing was creating a new rendering. That’s not an image. And this error happens when the dialog tried to open before I have a chance to even select anything. I know from playing with the wizards in Sitecore’s Sheer UI that each wizard view can have an associated image which is displayed. That’s the only image I could think of in this instance.

The error occurred when trying to save the image. What could cause an error in that case? The first thing that came to mind was file permissions. If I don’t have permissions to write to a location, that might cause an error. And that’s exactly what was happening. The account under which ASP.NET was running didn’t have permissions to write to the “temp” folder under the root of the website. I adjusted the permissions so the account could write there, and voila, the error was gone.

Advertisements

One thought on “A generic error occurred in gdi+

  1. Doug says:

    just thought i’d give you the heads up…

    this error is also quite common when trying write a resized PNG file to a memory stream which is caused by only using a one way seekable stream (the response stream)

    more info:
    http://www.west-wind.com/WebLog/posts/8230.aspx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

The views expressed on this blog are solely my own and do not necessarily reflect the views of my employer.
%d bloggers like this: