Page 1 of 1
Transport binary values over COM between X# and VO
Posted: Tue Sep 07, 2021 8:02 am
by wriedmann
Hi Robert,
is there any possibility to transport binary values over the COM interface between an X# COM module and a VO application? I need that for encrypted and/or compressed values.
For sure it would work if the value is converted for and back to Base64, but I would prefer to not need that because it not only blows up data by about 33%, but has also a non indifferent performance influence.
Wolfgang
Transport binary values over COM between X# and VO
Posted: Tue Sep 07, 2021 9:03 am
by robert
Wolfgang,
COM usually uses a SafeArray of Bytes for this.
I am afraid that this is not completely supported by VO.
SafeArray return values returned from the COM server will most likely be converted to a normal VO array where each element in the array represents a byte.
To send a Safe Array from VO you would have to create the SafeArray yourself and wrap it in a OleBinary object
The VO Ole Classes will know how to handle the OleBinary
Robert
Transport binary values over COM between X# and VO
Posted: Tue Sep 07, 2021 9:06 am
by wriedmann
Hi Robert,
thank you very much!
Il will look into it and let you know if I was able to do it, and then publish the code here.
Wolfgang
Transport binary values over COM between X# and VO
Posted: Tue Sep 07, 2021 9:39 am
by wriedmann
Hi Robert,
So if I understand it correctly, I have to do that:
1) from the VO application to the X# COM module I have to create a OleBinary object passing the binary string to the init method. On the X# side I should receive that as 1-based byte[] structure according to this article:
http://www.windows-tech.info/1/813f6954a4261c78.php and this here
https://weblog.west-wind.com/posts/2008 ... -Call-in-C
2) from the COM module I can pass a SafeArray structure to VO, and I will receive a VO array.
Thank you very much for your help!
Wolfgang
Transport binary values over COM between X# and VO
Posted: Mon Sep 20, 2021 5:55 am
by wriedmann
Hi Robert,
I have done now some tests.
From X#/COM to VO it works very well as you wrote:
X#:
Code: Select all
public virtual method GetByteArray() as byte[]
local aReturn as byte[]
local nI as int
aReturn := byte[]{ 256 }
for nI := 0 upto 255
aReturn[nI+1] := ( byte ) nI
next
return aReturn
VO:
Code: Select all
METHOD GetByteArray( ) CLASS ICOMTester
LOCAL oMethod AS cOleMethod
LOCAL uRetValue AS USUAL
oMethod := cOleMethod{}
oMethod:symName := String2Symbol("GetByteArray")
oMethod:iMemberid := 3
oMethod:wInvokeKind := INVOKE_METHOD
oMethod:bRetType := VT_UI1
uRetValue := SELF:__Invoke(oMethod, DWORD(_BP+16),PCount())
RETURN (uRetValue)
On the VO side I see a normal VO array of bytes.
The reverse after a bit of changes works also now:
X#:
Code: Select all
public virtual method SetByteArray( aData as byte[] ) as logic
System.IO.File.WriteAllBytes( System.IO.Path.Combine( AppDomain.CurrentDomain:BaseDirectory, "SetByteArray.txt" ), aData )
return true
VO:
Code: Select all
METHOD SetByteArray(;
aData; // AS USUAL
) CLASS ICOMTester
LOCAL oMethod AS cOleMethod
LOCAL uRetValue AS USUAL
oMethod := cOleMethod{}
oMethod:symName := String2Symbol("SetByteArray")
oMethod:iMemberid := 4
oMethod:wInvokeKind := INVOKE_METHOD
oMethod:nParams := 1
oMethod:lNamedArgs := TRUE
oMethod:cParamTypes := VTS_VARIANT
oMethod:bRetType := VT_BOOL
uRetValue := SELF:__Invoke(oMethod, DWORD(_BP+16),PCount())
RETURN (uRetValue)
and calling that with
Code: Select all
oOleBinary := OleBinary{ cBinString }
oComTester:SetByteArray( oOleBinary )
Thank you very much for your help!
I will add that now to my SQL server libraries and try it also with the VO RDD.
Wolfgang