Groups | Blog | Home
all groups > dotnet interop > december 2003 >

dotnet interop : Type Mismatch calling VT_UNKNOWN


dnoel NO[at]SPAM shore.net
12/12/2003 1:41:49 PM
have a C++ application that declares an Automation method
using the following signature:

DISP_FUNCTION(apauto, "DMIToSectionComponent",
DMIToSectionComponent, VT_BOOL, VTS_I4 VTS_UNKNOWN)

I would assume that I can use the following method
signature to pass an object into my C++ code

[DispId(228)] bool DMIToSectionComponent( int handle,
[MarshalAs(UnmanagedType.IUnknown)] object test );

But everytime I call this code, I get a Type Mismatch
error at Run Time.

I am calling the code along the following lines

object testObj = null;
iApolloAuto.DMIToSectionComponent( m_sectionID, testObj );

I have set a breakpoint in the C++ code inside the
DMIToSectionComponent.

In the same code base, I have been able to successfully
call other VTS_UNKNOWN params using the
UnmanageType.IUnknown syntax

I would appreciate any suggestions about next steps.

In particular, I am interested in how I can learn more
about the RCW type checking as it pertains to these types
of calls.
I am interested in learning about the different ways that
I can Marshall IUnknowns in order to
get more consistent results.

anonymous NO[at]SPAM discussions.microsoft.com
12/16/2003 7:31:42 AM

I figured out the problem. I get the Type Mismatch error
because my DispId was off by one.

Of course, I wanted to make the problem much more
complicated so I spent all kinds of time learning about
COM Smart pointers, custom marshalling and so on.




[quoted text, click to view]
AddThis Social Bookmark Button