Try to type the return value from
f
as a
IntPtr
instead of a
IntPtr[]
, then marshal that return value to a
IntPtr[]
, iterate over that and marshal each entry to a
double[]
.
Change
[DllImport("exDP.dll")]
public static extern IntPtr[] f(ref int n_);
to
[DllImport("exDP.dll")]
public static extern IntPtr f(ref int n_);
Then read the values like this;
int n = 0, i;
IntPtr ret = f(ref n);
List<double[]> doubleArrays = new List<double[]>();
IntPtr[] intPtrs = new IntPtr[2];
Marshal.Copy(ret, intPtrs, 0, 2);
for(int c = 0; c < intPtrs.Length; ++c) {
double[] array = new double[n];
Marshal.Copy(intPtrs[c], array, 0, n);
doubleArrays.Add(array);
}
The
IntPtr
can hold a reference to anything, including the
double**
result from the
C++ function.
Hope this helps,
Fredrik