MATLAB: SAFEARRAY COM interface invoke error Dispatch Exception: An invalid field name was used in a query string

com invoke error safearrayMATLAB

I am currently using MATLAB R2009a and am trying to work with a COM interface designed and functioning with multiple other languages (VB, VC++, LW/CVI, ATeasy) for years. It has a COM interface function with the IDL of
HRESULT Initialize (
[in] long lParam,
[in] double dParam,
[in, out] SAFEARRAY(double)* dParamAry
);
that keeps giving me the above error. I have tried giving it variables for all three (a double array and a cell array for the last, with and without feature('COM_PassSafeArrayByRef',1) enabled (1 and 0 set), tried supplying values for the first two and variables for the last, values for all three. The result is always the same.
Of course this is the first call that needs to be made before doing anything else can be done. The other functions can be called but they throw exceptions as expected due to this one not being called.

Best Answer

It ended up I needed to define the array as
dAry = [0.1;0.3]
also do
feature('COM_SafeArraySingleDim', 1);
and then it worked fine.
Beware that a single element array with 7.8.0 would be passed as an empty array with or without the feature flag. For my application this was fine (almost preferred) but others may not like it.