Link to home
Start Free TrialLog in
Avatar of jkwasson
jkwasson

asked on

A generic error occurred in GDI+ (trying to do image.save)

I have the following code. I am trying to create and save a .gif file. This works fine on my development box, but when I upload it to my hosted server, it fails with the error listed below. I have done some reading and this would indicate that I have a permissions issue on that folder, but I have verified that on my hosted server the anonymous permissions for the folder I am writing to allow for read/write. I am stumped...any help would be greatly appreciated.

My Code:

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Dim Image As Image
        Dim tmpImage As Image
        Dim bmMap As Bitmap
        Dim bmLogo As Bitmap
        Dim bmTemp As Bitmap
        Dim gMap As Graphics
        Dim strLogoPath As String = Server.MapPath("graphics/mt_pushpin.gif")
        Dim strMapPath As String = Server.MapPath("maps/us_nv.gif")
        Dim strBasePath As String = Server.MapPath(".")


        bmLogo = New Bitmap(strLogoPath)
        bmMap = New Bitmap(strMapPath)

        'create a temp bitmap that we will generate the new state image from
        bmTemp = New Bitmap(606, 336)
        tmpImage = bmTemp

        'overlay the state map onto the blank image
        gMap = Graphics.FromImage(tmpImage)
        gMap.DrawImage(bmMap, 0, 0)

        'draw the bullets on the image
        gMap.DrawImage(bmLogo, 200, 300)
        gMap.DrawImage(bmLogo, 52, 44)

        'save the image
        Dim strTemp As String
        strTemp = Server.MapPath("maps/us_nv_new.gif")
        Image = tmpImage
        Response.Write(strTemp & "<br>")
        Image.Save(strTemp, System.Drawing.Imaging.ImageFormat.Gif)


    End Sub

THE ERROR i AM GETTING:

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

stack trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
   System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +581
   System.Drawing.Image.Save(String filename, ImageFormat format) +61
   MTDealerMap.gditest.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\MTDealerMap\gditest.aspx.vb:62
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +750


Thanks!
jk
ASKER CERTIFIED SOLUTION
Avatar of apb2
apb2
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Elvio Lujan
Elvio Lujan
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jkwasson
jkwasson

ASKER

Thanks for your replies. I just got an email back from support at my hosting company and it looks like they figured it out. The problem was similar to permissions, but not exactly. My permissions were right, but the disk quota for my anonymous ASPNET user has somehow gotten set to zero. That doesn't allow him to write to disk....explains why it had me so baffled - because my permissions were set correctly. I am going to split the points between you guys for responding...

Thanks,
jk
cool, thanks for the points