I am trying to invoke a function in a C++ DLL from C#/.net. I believe there is something wrong with how I am marshaling the data. The function call runs but the return values (the last 7 variables) are all set to 0, and the arrays are set to length of 1 (I assume this is the DLL's intended behavior when it receives data it can't work with).
The C++ DLL is compiled as 32bit.
Here is the C++ header:
extern "C" __declspec(dllexport) void __stdcall Merchandize(int SppCode,
double DBH,
double TotHt,
double CR,
double BTR,
int *minDIBs, //array
int *minLens, //array
int *minVols, //array
int NumProducts, //array length
int maxLen,
double trimLen,
double stumpHt,
int logStep,
int *logLens, //array, understood to be 50
double *logSEDs, //array, understood to be 50
double *logVols, //array, understood to be 50
int *logGrades, //array, understood to be 50
int *NumberOfLogs,
double *merchHt,
int *errorFlag)
And here is the C# dll import:
[DllImport("C:\\Users\\Public\\Documents\\FVSNEMerchandizer.dll")]
static extern void MerchandizeTree(int SppCode,
double DBH,
double TotHt,
double CR,
double BTR,
ref int[] minDIBs,
ref int[] minLens,
ref int[] minVols,
int NumProducts,
int maxLen,
double trimLen,
double stumpHt,
int logStep,
ref int[] logLens,
ref double[] logSEDs,
ref double[] logVols,
ref int[] logProds,
ref int[] numLogs,
ref double merchHt,
ref int errorFlag);