Search This Blog

Tuesday, April 15, 2008

System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.

Try to upload picture and hit below error.

A generic error occurred in GDI+.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.

Source Error:

Line 469: MemoryStream mem = new MemoryStream();
Line 470: resizedImage.Save(mem, jpegICI, encoderParams);
Line 471: resizedImage.Save(filePath + "\\" + fileName, ImageFormat.Jpeg);
Line 472:

Source File: c:\Inetpub\wwwroot\BlogA\Account.aspx.cs Line: 471

Stack Trace:

[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +397778
System.Drawing.Image.Save(String filename, ImageFormat format) +69
Account.WarpImageDimensions(String filePath, String fileName, Bitmap imageToSave) in c:\Inetpub\wwwroot\BlogarateNewLayout\Account.aspx.cs:471
Account.ImageButton1_Click(Object sender, ImageClickEventArgs e) in c:\Inetpub\wwwroot\BlogA\Account.aspx.cs:392
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +86
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

in my case:

It's caused by 2 thing:
1. Upload path - i put the wrong path
2. Folder permission - set the correct permission. In my case, i allow write permission for internet user (IUSR_xxxxx).

Problem solved.

1 comment:

Unknown said...

My problem was number 2!