Why do I receive an error when trying to invoke a method on an object that has reference or optional arguments?

1 view (last 30 days)
Why do I receive an error when trying to invoke a method on an object that has reference or
optional arguments?
Consider a COM object that has a method with following signature:
[id(1), helpstring("method AllinOne")] HRESULT AllinOne([in] double db, [out] BSTR* strout,
[in, out] long* ln, [in,optional] BSTR strin, [out, optional] VARIANT* var,
[out,retval] BOOL* bret);
This is the code I use in MATLAB:
h=actxserver('TestServer.ArgTest.1');
[a,b,c,d] = invoke(h, 'AllinOne', 5.57, 10, 'test')
But MATLAB returns:
??? No method with matching signature.
As you can see, MATLAB incorrectly thinks the signature for the AllinOne method is as follows:
invoke(h)
AllinOne = [int32, string, int32] AllinOne(handle, double, int32, Variant(Optional))

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 17 Jan 2013
This problem has been fixed in MATLAB 6.5.1 (R13SP1). If you are using a previous version, read the following:
This issue has been addressed in updated versions of comcli.dll and newprogid.m. With this fix,
the correct signature is seen by MATLAB:
invoke(h)
AllinOne = [int32, string, int32, Variant] AllinOne(handle, double, int32, Variant(Optional))
You can now invoke methods with optional or reference arguments:
[a,b,c,d] = invoke(h, 'AllinOne', 5.57, 10, 'test')
a =
1
b =
[out] returned
c =
20
d =
[out,optional] returned
The updated versions of comcli.dll and newprogid.m should replace the current versions in your MATLAB installation. Both are available from the related solution below.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!