Cannot return an array of COM Objects

Paul Norrie <[email protected]> Sun, 15 Jan 2006 17:27:48 -0500
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <LISTSERV%[email protected]>
I have a function that returns an array of objects from a COM Object.  It is
of the form:

    HRESULT list([out, retval] SAFEARRAY(IAnimal*)* );
        Where IAnimal is a COM interface that inherits from IDispatch.

I have tried numerous methods of calling the list function and they all
throw COMException with the message:

    8000ffff: passed end of stream in the marshalling layer

Currently my code is:

    Variant p = (Variant)invoke("List");

but I've also tried:
    * DispatchPtr[] p = (DispatchPtr[])invoke("List");
    * Object[][] p = (Object[][])invoke("List");
    * Variant.Byref p = new Variant.Byref(new DispatchPtr[]);
      p = (Variant.Byref)invoke("List");

I don't know if this is any help but I've traced the code through the Java
sources of Jawin, and the instruction argument to the native invoke function
is ":V:".

I feel that I must be doing something fundamentally dumb.  How does one
return an array of COM objects?

Cheers
Paul