convert IntPtr to float **

L

Lisa

Hi all
I have to use unmanaged COM from .Net environment. This component does
some calculations on a two dimensional array of data and returns
another two dimentional array of processed data.
I've added a reference to this COM. Then I've instantiated an object
of its type. Now I want to call a ProcessData method of this object.
ProcessData method in the original C++ expects float** type as a
parameter (which is a two dimentional array of floats). I've tryed to
do something like this:

int [,]arrRaw1={{2,2,2},{3,3,3}};
int [,]arrFiltered1;
IntPtr arrRaw;
IntPtr arrFiltered;
Marshal.StructureToPtr(arrRaw1,arrRaw,true);
obj.ProcessData(arrRaw,arrFiltered);
Marshal.PtrToStructure(arrFiltered,arrFiltered1);

It does not work.
How to pass multidimentional array to/from unmanaged code?
Thanks for your help,
Lisa.
 
L

Lisa Shmulevich

Hi Peter,
Thanks for the answer.
I have this definition in the .tlb file:
[in, size_is(4, theDataLength)] float** theRawData,
[in, out, size_is(4, theDataLength)] float** theFilteredData,
I was trying to put definition like this in the .il file:
[in] float64[,] marshal([]) theRawData,
[in][out] float64[,] marshal([]) theFilteredData,
It compiles and runs, but when the COM object code is reaching this
line:
float a = theRawData[0][0];
it throws the System.NullReferenceException
How should I define 2-dimentional array of floats?
Thanks for your help,
Lisa.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top