A generic error occurred in GDI+
I know how frustrating it can be debugging this problem. One case when
it occurs is when you try to save an image created from a Stream e.g.
using Bitmap Save function.
Few things to consider overcoming this error:
- Make sure you allow the write permission on the folder where image is being saved.
- Release resources after saving the image. For example if you
create a Bitmap object from a stream dispose resource by bmp.Dispose()
or similar syntax
I will suggest using a try catch finally block like this (I am using C# here):
Bitmap bmp = null;
try
{
bmp = new Bitmap(myPostedFile.InputStream, false);
//save image, do things here
}
catch
{
}
finally
{
if (bmp != null)
{
bmp.Dispose();
}
}
Was it Enough to Solve this Error?
In my case it wasn't able to solve the problem.
Solution
Redirect after every the save reloading the page again as fresh.
This way it will make sure all the resources being hold will be
released and reloaded. Sounds stupid right? In my case it solved the
problem.
Example C# Redirect Code: Response.Redirect("MyPage.aspx",false);