Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
430
DisplayLayout:SaveAsXml
posted

When I run this method (DisplayLayout:SaveAsXml), I get the following error

System.Runtime.InteropServices.ExternalException: A generic error occured in GDI+

Here is the code that raises this error.

/* First I dynamically create valuelist items and attach to valuelist assigned to the grid column */

        bands = curGrid:DisplayLayout:Bands.
        curBand = CAST(bands[0],Infragistics.Win.UltraWinGrid.UltraGridBand).
        bandColumns = curBand:Columns.
        curColumn = bandColumns["RequestIdImage"].
        curColumnVl = CAST(curColumn:ValueList,Infragistics.Win.ValueList).
        curColumnVl:ValueListItems:Clear().
       
        AppStatic:WorkflowRequestIdList = "".
        FOR EACH BRequestId NO-LOCK BY BRequestId.RequestId:
            AppStatic:WorkflowRequestIdList = AppStatic:WorkflowRequestIdList +
                IF AppStatic:WorkflowRequestIdList EQ "" THEN
                    BRequestId.RequestId
                ELSE
                    "," + BRequestId.RequestId.                                                                       
        END.
       
        EXTENT(valueListItems) = NUM-ENTRIES(AppStatic:WorkflowRequestIdList).

        DO i = 0 TO NUM-ENTRIES(AppStatic:WorkflowRequestIdList) - 1:
            valueListItems[i + 1] = NEW Infragistics.Win.ValueListItem().
            valueListItems[i + 1]:DataValue = System.Convert:ToInt16(i).
        END.
       
        curColumnVl:ValueListItems:AddRange(valueListItems).

/* Next I assign the image property for each dynamically created valuelistitem */

        DO i = 0 TO NUM-ENTRIES(AppStatic:WorkflowRequestIdList) - 1:
            curColumnVlI = CAST(curColumnVl:ValueListItems:Item[i],Infragistics.Win.ValueListItem).
            FIND BAppImages NO-LOCK WHERE
                BAppImages.AppKey EQ "BPM_Request_ID" AND
                BAppImages.AppValue EQ ENTRY(i + 1, AppStatic:WorkflowRequestIdList) AND
                BAppImages.AppSeq = 0 NO-ERROR.
               
            IF NOT AVAILABLE BAppImages THEN DO:
                ASSIGN curColumnVlI:Appearance:Image = ?.
                NEXT.
            END.       

            myLongChar = BAppImages.AppImage.
            theAppImage = CAST(CONVERT:Base64ToImage(myLongChar),     /* see method below */

            System.Drawing.Image).curColumnVlI:Appearance:Image = theAppImage.

       END.

    METHOD PUBLIC STATIC System.Drawing.Image Base64ToImage
        ( INPUT base64String AS CHARACTER ):
       
        DEFINE VARIABLE myImage         AS System.Drawing.Image   NO-UNDO.
        DEFINE VARIABLE myMemoryStream  AS System.IO.MemoryStream NO-UNDO.
       
        DO TRANSACTION:
            ASSIGN
                myMemoryStream = NEW      

                    System.IO.MemoryStream(System.Convert:Frombase64String(base64String))
                    myImage = NEW System.Drawing.Bitmap(myMemoryStream)
                .
   
            myMemoryStream:Dispose().
            DELETE OBJECT myMemoryStream.
           
            CATCH e AS Progress.Lang.Error :
                   
            END CATCH.
           
        END.
       
        RETURN myImage.

 

If I change the above code to the code below assign the image property using an OrderedDictionary collection, I don't get the error.

This is the method that builds the collection (it is built up when the software launches)

   METHOD PUBLIC VOID SetImageCollection
        ( INPUT cImageType AS CHARACTER,
          INPUT cImageName AS CHARACTER,
          INPUT cImageFile AS CHARACTER):
             
        DEFINE VARIABLE cTmpChar AS CHARACTER NO-UNDO.
       
        cTmpChar = STRING(cImageType + "|" + cImageName).
       
        ImageListCollection:Item[cTmpChar] =
            System.Drawing.Image:FromFile(cImageFile).
       
    END METHOD. /* SetImageCollection */

This is the method that gets the image out of the collection that is assigned to the value list image property

    METHOD PUBLIC System.Drawing.Image GetStoredImage
        ( cImageType AS CHARACTER,
          cImageName AS CHARACTER ):
       
        DEFINE VARIABLE curImage AS System.Drawing.Image NO-UNDO.
        DEFINE VARIABLE cTmpchar AS CHARACTER NO-UNDO.
       
        cTmpChar = STRING(cImageType + "|" + cImageName).
       
        curImage =
            CAST(ImageListCollection:Item[cTmpChar],System.Drawing.Image)
            NO-ERROR.
        IF VALID-OBJECT(curImage) THEN
            RETURN curImage.
        ELSE
            RETURN ImageDefault.
       
    END METHOD. /* GetStoredImage */

So if I change my code above from

            myLongChar = BAppImages.AppImage.
            theAppImage = CAST(CONVERT:Base64ToImage(myLongChar),     /* see method below */

            System.Drawing.Image).curColumnVlI:Appearance:Image = theAppImage.

to this... /* just hardcoded a key value that I know is in the collection */

             curColumnVlI:Appearance:Image = AppStatic:FrameworkConstants:GetStoredImage*/
                    ( INPUT "Workflow", INPUT "Critical").

it works fine

What I don't understand is what the difference is since both GetStoredImage and Base64ToImage both return type System.Drawing.Image.

Any help would be appreciated.

 

Doug

 

 

 

 

 

 

 

 

 

 

  • 469350
    Offline posted

    Hi Doug,

    It's very hard to tell what's happening from the code snippets and the error message you listed here.

    Can you post a small sample project demonstrating the exception? You can attach a zip file to your post by going to the Options tab.

    If you cannot do that, then posting the entire call stack of the exception might help.