[Mono-dev] COM Interop changes for COM objects in VARIANTs

Bill Holmes billholmes54 at gmail.com
Tue Dec 9 15:01:52 EST 2008


Hi,

The attached patches should only apply to COM interop.

They fix some inconsistencies that we found in mono dealing with
VARIANTs.  When an IUnknown (or IDispatch) object is passed as a
VARIANT to native code the vt field was different with mono.

There is not great documentation for this but what I was able to pull
together was the following.
When a native object is wrapped with a VARIANT a QI is performed to
determine if IDispatch is supported.  If so then VT_DISPATCH is the
value of vt otherwise VT_UNKNOWN.
Managed object are the same, but it is the question of when a managed
object supports Dispatch that is the tricky part.  From what I have
read and what I have observed a public object with the ComVisible
attribute set to true support IDispatch.  All others only support
IUnknown.

-bill


For CCW_Dispatch.diff
2008-12-09  Bill Holmes  <billholmes54 at gmail.com>

        * object-internals.h : Adding a definition for
          MonoReflectionComVisibleAttribute.

        * marshal.c (cominterop_com_visible) :  Method added to check the
          ComVisible attribute of a class.

        * marshal.c (cominterop_raise_hr_exception, cominterop_get_interface) :
          cominterop_raise_hr_exception added to consolidate common code
          to raise hr exceptions.

        * marshal.c (cominterop_can_support_dispatch) :  Method added
to determine
          if a managed class should support IDispatch.

        * marshal.c
          (cominterop_get_idispatch_for_objec, cominterop_ccw_queryinterfacet) :
          Added additional checks for managed object when getting
          an IDispatch interface.

        Code is contributed under MIT/X11 license.


For VARIANT.diff
2008-12-09  Bill Holmes  <billholmes54 at gmail.com>

        * Variant.cs (SetValue):   Changing the behavior for COM object in
          VARIANTs to match MS.  Also adding support for BStrWrapper,
          UnknownWrapper, and DispatchWrapper.

        Contributed under MIT/X11 license.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CCW_Dispatch.diff
Type: application/octet-stream
Size: 5195 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20081209/391da485/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: VARIANT.diff
Type: application/octet-stream
Size: 1801 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20081209/391da485/attachment-0003.obj 


More information about the Mono-devel-list mailing list