Hello. It does not work.
I allocated a IntPtr and could do a GetNativeVariantForObject, but when
I pass it to the COM-Method it says "COM Exception: Type Mismatch".
Same when I just pass it directly.
The Methods's parameter is declared as VARIANT* data
Any idea?
Sebastian
> Hello. It does not work.
> I allocated a IntPtr and could do a GetNativeVariantForObject, but when
[quoted text clipped - 4 lines]
>
> Any idea?
Hi Sebastian,
Often you don't need to 'hack' arrays yourselves, in fact, you seldom would
need to. Sample
So if your method is PInvoked this would be good enough
[DllImport("myDLL.dll",
CharSet=CharSet.Unicode,
EntryPoint="yourmethod",
SetLastError=false, ExactSpelling=true)]
public static extern int Blah(ref object yourvariant); <- note the ref!
since your method is VARIANT*
[DllImport("myDLL.dll",
CharSet=CharSet.Unicode,
EntryPoint="GenerateLicense",
SetLastError=false, ExactSpelling=true)]
public static extern int Blah(
[MarshalAs(UnmanagedType.BStr)] string domain,
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)]
string[] serversList,
[MarshalAs(UnmanagedType.BStr)] ref string theBstr);
In ATL the declaration is as follows (the in/out comments were added for
readability)
STDMETHODIMP Blah(/*in*/ BSTR domain,
/*in*/ SAFEARRAY* serversList,
/*in,out*/ BSTR * theBstr);
if serversList were a VARIANT array, just make the VarEnum.VT_VARIANT or
just leave out the whole declaration since object[] serverList would be
implicitely compiled by the compiler that way.
Sebastian W - 06 Oct 2005 09:45 GMT
Hi Thanks for the answer.
The problem is - this method is part of Class of a ActiveX-Control. The
IDE has created the two Wrappers (AxBlah and InteropBlah) for the
Component.
Therefore I cannot use the DLLImport Statement, right?
What can I do?
Is it possible to write this into the IL Code of the wrapper libarys?
Sebastian