I had this procedure:
PROCEDURE ByteArrayToMemptr : DEFINE INPUT PARAMETER poBytes AS "System.Byte[]":U NO-UNDO. DEFINE OUTPUT PARAMETER myMemptr AS MEMPTR NO-UNDO. DEFINE VARIABLE oIntPointer AS System.IntPtr NO-UNDO . MESSAGE 1 " : " poBytes:Length . SET-SIZE (myMemptr) = poBytes:Length . MESSAGE 2. oIntPointer = NEW System.IntPtr (GET-POINTER-VALUE (myMemptr)). MESSAGE 3. System.Runtime.InteropServices.Marshal:Copy (poBytes, 0, oIntPointer, poBytes:Length). MESSAGE 4. DELETE OBJECT oIntPointer. END PROCEDURE.
But since upgraded to 11.7, it won't work.
The message were inserted to debug.
when run, poBytes:Length is 512, and message 3 & 4 never get shown.
The error is "System.OverflowException: value too big or to little for Int32
We ran into something similar - get-pointer-value is returning a lot more 64 bit values in 11.7 than in 11.6 where they all seemed to be 32 bit. According to support "The same issue could potentially have been encountered in 11.6.3 but it is much more likely to happen in 11.7 on Windows 8.1 and Windows 10 because of a) a change to how we compile OpenEdge executables and b) a change in newer versions of Windows"
In your case however it seems that the wrong signature is being determined for System.IntPtr - maybe you can work-around it by using an intermediate int64 to store your get-pointer-value.
We ran into something similar - get-pointer-value is returning a lot more 64 bit values in 11.7 than in 11.6 where they all seemed to be 32 bit. According to support "The same issue could potentially have been encountered in 11.6.3 but it is much more likely to happen in 11.7 on Windows 8.1 and Windows 10 because of a) a change to how we compile OpenEdge executables and b) a change in newer versions of Windows"
In your case however it seems that the wrong signature is being determined for System.IntPtr - maybe you can work-around it by using an intermediate int64 to store your get-pointer-value.
Thanks Stefan!!!
That was it!!!
Thanks Stefan!!
That was it!!!
Hi, could you share the answare ? :-)
This works for me:
/** * Purpose: Converts a .NET Byte[] to an ABL MEMPTR * Notes: * @param poBytes The System.Byte[] to convert to a MEMPTR * @return The new MEMPTR with the data from the Byte[] */ METHOD PUBLIC STATIC MEMPTR ByteArrayToMemptr (poBytes AS "System.Byte[]":U): DEFINE VARIABLE mptr AS MEMPTR NO-UNDO . DEFINE VARIABLE oIntPointer AS System.IntPtr NO-UNDO . DEFINE VARIABLE iPtr64 AS INT64 NO-UNDO . DEFINE VARIABLE iPtr32 AS INTEGER NO-UNDO . SET-SIZE (mptr) = poBytes:Length . IF SessionHelper:ProcessBitness() = 32 THEN DO: iPtr32 = GET-POINTER-VALUE (mptr) . oIntPointer = NEW System.IntPtr (iPtr32). END . ELSE DO: iPtr64 = GET-POINTER-VALUE (mptr) . oIntPointer = NEW System.IntPtr (iPtr64). END. System.Runtime.InteropServices.Marshal:Copy (poBytes, 0, oIntPointer, poBytes:Length). RETURN mptr . FINALLY: IF VALID-OBJECT (oIntPointer) THEN DELETE OBJECT oIntPointer. END FINALLY. END METHOD .
And then
/*------------------------------------------------------------------------------ Purpose: Returns the "bitness" of the current process (32 / 64 bit) Notes: @return 32 or 64 depending on the current Process process ------------------------------------------------------------------------------*/ METHOD PUBLIC STATIC INTEGER ProcessBitness (): &IF DEFINED (DotNetAccessible) NE 0 &THEN &IF PROVERSION BEGINS "10" &THEN RETURN 32 . /* no 64 bit Progress on Windows on OE10 */ &ELSE IF System.Environment:Is64BitProcess THEN RETURN 64. ELSE RETURN 32. &ENDIF &ELSE RETURN 64. /* no 32 bit Progress on Linux anymore */ &ENDIF END METHOD .
If on a not too old version, you can use the built in PROCESS-ARCHITECTURE function to get the bitness.
... "not too old" being 11.3.0+
I got a good one from Mike, so everything is swell...
3. feb. 2020 kl. 16:04 skrev Stefan Drissen <bounce-14941@community.progress.com>:
<ProgressEmailLogo-png_2D00_150x42x2-png>Update from Progress Community
Stefan Drissen If on a not too old version, you can use the built in PROCESS-ARCHITECTURE function to get the bitness.
You received this notification because you subscribed to the forum. To unsubscribe from only this thread, go here.
Flag this post as spam/abuse.
|
You need to use an intermediate int64 variable to pick up the correct signature.