Click here to Skip to main content
15,845,103 members

Comments by oleg63 (Top 11 by date)

oleg63 30-Jan-20 11:31am View    
Thanks, but it's not the ultimate solution to problems with the large mixed languages code base.

Waiting for the Address Sanitizer to be able work on 64-bit.
oleg63 17-Apr-15 12:22pm View    
Wendell D H,
Thank you very much. Everything is working.
You are the MAN of the day...
- Have a good day :)
Oleg.
oleg63 14-Apr-15 16:57pm View    
You will end up with such trash, if your COM server would require support any kind of clients(early binding, and late binding), and only automation types will do the job.
oleg63 14-Apr-15 16:45pm View    
So, let's start...
There is a COM server, which has a routine:
[id(332), helpstring("method GetAMatrix")] HRESULT GetAMatrix([in] LONG iDimensions,[out] VARIANT *saMatrix,[in,out] SHORT* iErr);

iDimensions - dimensions of square matrix(for 3 dim, it would be matrix 3X3 ;)
saMatrix - the square matrix of beforemensioned size, which is formed by COM server as 2D SAFEARRAY of VARIANTs(internally each VARIANT variable is type of double, vt = double).
On C# side we have:
private void button_test_Click(object sender, EventArgs e)
{
Int32 iDim = 3;
object saMatrix = null;
theCOM.GetAMatrix(iDim, out saMatrix, ref iErr);
double[,] dArray = new double[iDim, iDim];
//put your conversion from saMatrix to dArray HERE ;)
...
}

C# object browser has the COM routine description:
GetAMatrix( int, out object, ref short)

Returned matrix look(from the C# debugger):
- saMatrix {object[3, 3]} object {object[,]}
[0, 0] 11.0 object {double}
[0, 1] 12.0 object {double}
[0, 2] 13.0 object {double}
[1, 0] 21.0 object {double}
[1, 1] 22.0 object {double}
[1, 2] 23.0 object {double}
[2, 0] 31.0 object {double}
[2, 1] 32.0 object {double}
[2, 2] 33.0 object {double}

I guess it's detailed enough(if you know the COM :)

The casting technique, which I've described earlier work only on one-dimensional arrays, and do not work for 2D arrays, which is my matrix. This is a problem. Oh, a Goal... ;-\ - pass the matrix(basically 2D array of double type) from COM server to the C# client...

So what do think about it???


oleg63 14-Apr-15 15:39pm View    
SA, sorry if I in some way hurt you. But it's very basic straightforward conversion of square matrix NxN type of object, to the absolutely same dimensioning (2D array), but type of double.
I've found how to do that for 1D arrays, but I need conversion for 2D arrays.
Thanks for the answer.