[Mono-dev] Status of COM interop

Ivo Smits Ivo at UFO-Net.nl
Wed Apr 27 15:07:56 EDT 2011


Jonathan,

(Sorry, I accidentally replied directly the first time)

The CCW is working now. It turns out that the code I used to debug the 
issue did not work as well as the non-debugging code. I'm not sure why I 
introduced the debugging code anyway, perhaps something else was wrong 
at that time.

Maybe the COM interfaces are IUnknown on Linux/XPCOM and dual on 
Windows/COM? In that case it's probably more of a VirtualBox issue, 
rather than a problem in mono.

Using InterfaceType(IUnknown) works on Linux, but raises exceptions on 
Windows (HRESULT: 0xC0000005 and System.ExecutionEngineException for two 
different calls I have tested). Using InterfaceType(Dual) works on 
Windows, but produces incorrect results on Linux. In particular, it 
appears as if the vtable is shifted - the value of a property 4 places 
down in the interface is returned (for one property get accessor I have 
tested).

I will probably release the code some time soon.

--
Ivo

Op 26-4-2011 23:13, Jonathan Chambers schreef:
> Ivo,
>
> Both RCWs and CCWs should be working in mono. Please post more details 
> of the issues you are hitting. I am using both RCWs and CCWs 
> extensively in my applications.
>
> The InterfaceType attribute is interesting. I believe interfaces are 
> dual by default (IDispatch based with a vtable), so if your interfaces 
> really are dual this should work.
>
>
> Thanks,
> Jonathan
>
> On Tue, Apr 26, 2011 at 4:47 PM, Ivo Smits <Ivo at ufo-net.nl 
> <mailto:Ivo at ufo-net.nl>> wrote:
>
>     In Mono COM/XPCOM interop, Runtime Callable Wrappers appear to be
>     implemented and work correctly with VirtualBox, although it's not
>     directly compatible with COM interop in the Microsoft .Net
>     runtime: the
>     interop assemblies generated by VS.Net cause crashes (segmentation
>     fault) and for interfaces written in C#, Mono needs the
>     [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] attribute on the
>     interfaces, while this attribute breaks the interface in MS .Net. If
>     anyone has more information, or would like to have more
>     information, let
>     me know. For now, I will work around this by using different, equally
>     named interop assemblies exposing the same interfaces.
>
>     I have not been able to get COM Callable Wrappers to work yet. I
>     can get
>     an IUnknown interface pointer for the managed object (using
>     Marshal.GetIUnknownForObject), I can use Marshal.AddRef on this
>     pointer,
>     and I can pass this pointer to the COM code. Presumably when the COM
>     code makes a call on the CCW interface, a segmentation fault occurs.
>     This is still pretty much a black box for me, so before I investigate
>     any further: have CCWs been implemented in Mono and are they
>     supposed to
>     work? Has anyone successfully used them?
>
>     The stack trace of the crash is short and not very useful:
>     Native stacktrace:
>
>     Segmentatiefout
>
>     --
>     Ivo
>     _______________________________________________
>     Mono-devel-list mailing list
>     Mono-devel-list at lists.ximian.com
>     <mailto:Mono-devel-list at lists.ximian.com>
>     http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110427/0e94dfe1/attachment-0001.html 


More information about the Mono-devel-list mailing list