I'm early binding to a COM component, calling a method with the following
IDL:

HRESULT MethodName(
                [in] BSTR Parameter1,
                [in] BSTR Parameter2,
                [out, retval] VARIANT* ReturnParameter);

When I call this I get the following exception message:

"An unhandled exception of type
'System.Runtime.InteropServices.SafeArrayTypeMismatchException' occurred in
...

Additional information: Specified array was not of the expected type."

I've had some help debugging this, and it gets into the C++ code with the
correct parameters, and successfully
gets through all the method, and only bombs on its return.

The IL for the interop-wrapper looks like this:

.method public hidebysig newslot virtual
        instance object
        marshal( struct)
        MethodName([in] string  marshal( bstr) Parameter1,
                       [in] string  marshal( bstr) Parameter2) runtime
managed internalcall
{
  .custom instance void
[mscorlib]System.Runtime.InteropServices.DispIdAttribute::.ctor(int32) = (
01 00 07 00 02 60 00 00 )                         // .....`..
  .override ProgId::MethodName
} // end of method

apparently the variant returned is a VT_ARRAY | VT_I1 (although I don't
quite know what this means!).

any ideas?

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to