A generic error occurred in GDI+
[ExternalException (0x80004005): A generic error occurred in GDI+.] System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) +615257
I have a webpage in which a pdf is conve开发者_StackOverflowrted to png, and using the response.outputstream it is displayed. when i run this on my local machine is works fine. but when i run the same code on server is throws this exception.
my question is , where i could look in for error. as there is no inner exception or any other information provided. only clue is that it's happening on Image.Save , but the same code works perfectly fine on my local machine , then y is it not working on production???
http://blog.maartenballiauw.be/post/2008/05/13/ASPNET-MVC-custom-ActionResult.aspx
this is the example i am following
Take a look at the big "Caution" note in the System.Drawing documentation. All kinds of weird stuff can happen when you use something intended for desktop processing in a service process.
Check the usuals like permissions, path existence, framework version, etc.
This worked for me. Writing to MemoryStream and then Write the MemoryStream to the Output. Reasoning and code is here: https://weblog.west-wind.com/posts/2006/Oct/19/Common-Problems-with-rendering-Bitmaps-into-ASPNET-OutputStream
I changed my Image over load method to
Image.Save(context.HttpContext.Response.OutputStream, ImageCodecInfo encoder, EncoderParameters encoderParams)
earlier i was using Image.Save(context.HttpContext.Response.OutputStream,ImageFormat)
after changing the overload method for save , it fixed the error.
I installed my application on a Windows 7 machine by running as administrator.
This worked for me.
I had something similar a while back ... usually to do with security. Don't copy the png over from dev, (if you have one) the server probably won't be able to overwrite and make sure the asp proccess has write access to the dir you're attempting to save to.
It is probably that the asp.net worker process does not have permision to create a file where you are trying to save the image on the server.
This happened for me when the file already existed. Deleting the file before save resolved the problem. What an incredibly unhelpful error message.
精彩评论