good old generic error in GDI+ RRS feed

  • Question

  • User1107894578 posted

    Hello all, I'm having a very weird issue with some imaging code.


    Here is what I'm trying to do.

    I have an InfoPath form where my users attach pictures in the form. I run (try to run) code that takes the image and resize it and replace that image with an optimized one. So far all I have is this.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim retval As Image

    retval = Image.FromFile("C:/Temp/ali.gif")

    Dim mystring As String

    mystring = Me.ImageToBase64String(retval, retval.RawFormat)

    End Sub

    Public Function ImageFromBase64String(ByVal base64 As String) As Image

    Dim memory As New IO.MemoryStream(Convert.FromBase64String(base64))

    Dim result As Image = Image.FromStream(memory)


    Return result

    End Function

    Public Function ImageToBase64String(ByVal myImage As Image, ByVal format As Imaging.ImageFormat) As String


    Dim memory2 As New IO.MemoryStream()

    myImage.Save(memory2, myImage.RawFormat)

    Dim base64 As String

    base64 = Convert.ToBase64String(memory2.ToArray())


    Return base64

    End Function


    This code works great and error free when in a windows application. But when I put this same exact code in InfoPath, I get the dreaded "Generic Error in GDI+" Why is this? Thanks!!!!

    Tuesday, September 23, 2008 11:21 AM

All replies

  • User-1573490007 posted

    Possibly threading or permission issues.

    Be -very- careful about using GDI+ in anything service or server related (like asp.net or anything based on it), as it is NOT supported, officially... so if you get in trouble and no one can help on forums...you're out of luck...try to do without as much as you humanly can.

    Tuesday, September 23, 2008 11:31 AM
  • User1107894578 posted



    Yeah, it's very weird, I can call either function on it's own and it will work perfectly. But when I call them both, for example

     grab base64 sting, turn it into an image and turn it back into a base64 string, it gives me the generic gdi+ error. Very odd.

    Tuesday, September 23, 2008 11:38 AM