I want to call, using COM, a function with the following signature:
void GetCompoundList(ref object compIds, ref object formulae, ref object names, ref object boilTemps, ref object molwts, ref object casnos)
I have no access to the implementation, but the objects are of Variant type containing SafeArrays of String and Double, and are all out parameters.
Here is how I declare the arrays and call the function:
Array thermoCompounds = null;
Array thermoCompFormulae = null;
Array thermoCompName = null;
Array thermoCompTemp = null;
Array thermoCompWei = null;
Array thermoCompCAS = null;
ppThermoComp.GetCompoundList(thermoCompounds, thermoCompFormulae, thermoCompName, thermoCompTemp, thermoCompWei, thermoCompCAS);
Where ppThermoComp is an instance of the class implementing the interface.
However, the function call has no effect: the arrays are still null after the call.
- If I initialize the arrays at the right size, no change: the function has no effect either
- If I call another function from the same COM interface with different arguments (e.g. an array which is returned), it works
- If I call this function from a C++ code (still through COM), it works
C++:
CComVariant cIdsM, cFormulaeM, cNamesM, cTempM, cWeiM, cCASM;
HRESULT hr = thermocompoundsMat->GetCompoundList(&cIdsM, &cFormulaeM, &cNamesM, &cTempM, &cWeiM, &cCASM);
Any idea what is wrong with my C# code?