?
Solved

System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+ (cannot do Image.save after server switch).

Posted on 2010-11-15
4
Medium Priority
?
1,676 Views
Last Modified: 2012-05-10
I have a web application that is using image.save to update graphics and save it back to the disk. However, after switching from server 2003 to 2008 R2(IIS 7.5), it stopped working, and gives me the old "System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+ ". After research, I've tried several solutions which usually fixes it, but they don't work. Here is what I've tried.
1. Add IIS AppPool\DefaultAppPool and give it write access, that should allow anonymous user to write to disk.
2. add graphic.dispose() and Image.dispose() as given by MS kb article, it didn't work.

Can anyone help? my code is like this.
 Dim Image1 As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath("images/1.jpg"))

            Dim oGraphic As Graphics = Graphics.FromImage(Image1)
        
            Dim oColor As System.Drawing.Color = Color.Black
            Dim sText As String = Request.QueryString("username")
            Dim dateText As String = DateTime.Now.Date
            Dim oBrush As New SolidBrush(Color.White) 'background
            Dim oBrushWrite As New SolidBrush(Color.Black) 'text
            oGraphic.FillRectangle(oBrush, 668, 600, 468, 60)
            Dim oFont As New Font("Arial", 24)
            Dim oPoint As New PointF(450.0F, 280.0F)
            oGraphic.DrawString(sText, oFont, oBrushWrite, oPoint)
            oGraphic.DrawString(dateText, oFont, oBrushWrite, New PointF(450.0F, 500.0F))
     
            Image1.Save(Server.MapPath("gen_img2.jpg"), ImageFormat.Jpeg)
            oGraphic.Dispose()
            Image1.Dispose()

Open in new window

0
Comment
Question by:ffayyca1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Expert Comment

by:niralshah
ID: 34142779
0
 
LVL 1

Accepted Solution

by:
ffayyca1 earned 2000 total points
ID: 34144879
I renamed the output file, and that worked.
0
 
LVL 7

Expert Comment

by:niralshah
ID: 34144910
You have found solution from the link i have sent you. So you should accept my solution as your answer.

Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question