COMException - Type Mismatch - VARIANT* and SAFEARRAY

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi folks,

I'm trying to call a COM method that has the following signature:

long Foobar(long category, VARIANT* handle_list);

The documentation says that handle_list is a SAFEARRAY of longs (int32) that
will be populated by the function. Tlbimp (regardless of /sysarray) gives me
a signature like:

int32 Foobar(int32 category, ref object handle_list);

The IL uses: object& marshal (struct) handle_list

Is there any way to call this function from .NET? No matter what I seem to
supply, I always get a "COMException - Type Mismatch". I've tried creating
arrays and wrapping them in objects, etc to no avail. It seems that even if I
was able to send over an array, the COM function wants to allocate/fill it,
which is going to cause problems.

Thanks,
-G

At this point, I'm wondering if the best approach would be to write a small
C++/VB library that will accept the raw SAFEARRAY, wrap it, and pass it to
the library.
.



Relevant Pages

  • Re: pinvoke and AdjustWindowRect
    ... Tom Dacon ... signature does not match the unmanaged target signature. ... public static extern bool AdjustWindowRect(ref Win32RECT clientCorners, ... Int32 dwStyle, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Problems with RSA.SignData
    ... large byte arrays and then write them to disk. ... The problem is when I am calling the SignData method within a loop for many ... Dim Signature() As Byte ... Dim RSA As RSACryptoServiceProvider ...
    (microsoft.public.dotnet.security)
  • Re: Code calls method with wrong signature (object vs object[])
    ... where the signature only accepts a single object. ... My guess is since object is the base class of most items ... arrays of value types aren't. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Using 2 dimensional SAFEARRAYS with COM
    ... For example a SAEEARRAY of arrays. ... declare it as a function parameter. ... But how do I do this with a SAFEARRAY of arrays for BYTES. ... A Safearray is just another kind of Variant, ...
    (microsoft.public.vb.com)
  • SafeArray Pointer(string)
    ... I greatly appreciate that this has been treated in other threats ... ... but I seem to be incapable of calling the following object ... Output_GetProfiles(handle, int32, SafeArray Pointer(string)) ...
    (comp.soft-sys.matlab)