Click here to Skip to main content
15,350,252 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.
oleg63 14-Apr-15 13:35pm View
   
It's fun to see you as "Top Expert in 24hrs".
Looks like answers like this work as well ;)
oleg63 14-Apr-15 10:36am View
   
Thanks Sinsa,
So far I've found 2 types of conversions, but they both work on 1D array.
Like:
double[] E_x = ((object[])_x).Cast<double>().ToArray();
Array.ConvertAll<object, double>(...)
oleg63 14-Apr-15 10:10am View
   
Yes, it does.
It's square matrix. Essentially it passed back to the C# client from COM interface as safearray of variants(which are double type).
On C# side, I see it as described above.
It's need to be converted in 2D matrix of double.
So, if you know the answer, please submit it below,
if don't, just do not pollute the forum with the useless answers.
oleg63 11-Jan-13 17:17pm View
   
Thanks Rob,
But I use only automatin types. It was verified on first place.
I have a very heavy project, now I'm stripping down it to purely MFC MDI project.
Just making sure another application stuff is not affecting the COM interface.
oleg63 10-Jan-13 13:16pm View
   
But everything must work from Excel as well.
Now I'm checking on proper TLB embedment inside the executable.
oleg63 10-Jan-13 11:58am View
   
Thanks Max,

Yes, some methods are affected, some are not during the Excel VBA calls.
The same routines doesn't work if I call them from MATLAB.
Interestingly the MATLAB can see the all COM interface methods, but when I try to call problematc ones, it reports - "Error: method or property not found".