[Mono-list] COM / DCOM in Mono

Eran Sandler Eran.Sandler@smarteam.com
Wed, 5 Mar 2003 13:48:01 +0200

Actually what I'm trying to do is a little different and I don't think I
can make it work on Windows.=20

What I was thinking was on the lines of implementing the Com Callable
Wrapper (CCW) in Mono so instead of creating the objects as in-processes
COM objects (which it can't because we are running on Linux), I will
actually create them as DCOM objects.

In this manner Mono, at first, will have a COM implementation that will
require someone who wants to run an ASP.NET application calling COM
objects, to install a Windows machine along side the Linux+Mono machine
and configure all the COM objects there as DCOM (using the dcomcnfg

This will eliminate the need to re-implement and support the whole COM
infrastructure that exists in Windows.

To do this I have started to investigate how is the CCW implemented in
Windows and what things do I need to implement. After I'll find out what
needs to be implemented I will have to do 2 things:

1) Implement a DCOM client for Linux.
2) Understand where to intercept CCW calls and re-implement my own CCW
that will use the DCOM client.

I have found an article written by Frank Rem on iDevResource.com about
implementing a DCOM client in Linux using FreeDCE. I will try to base
the code on it and see if I can, at first, call a simple DCOM object
running on a Windows machine.=20

Form there on, the road should be relatively simple until a FULL COM
implementation for Linux will work (or the integration of Wine ;-),
which ever comes first).


-----Original Message-----
From: Paolo Molaro [mailto:lupus@ximian.com]=20
Sent: Wednesday, March 05, 2003 1:01 PM
To: mono-list@ximian.com
Subject: Re: [Mono-list] COM / DCOM in Mono

On 03/05/03 Eran Sandler wrote:
> Well, I'm currently investigating how implement DCOM on other systems.
> know it WAS implemented for UN*X and Linux by 3rd party companies but
> they didn't release the code.
> Working with DCOM shouldn't be that hard since I only need a proxy
> and a way to marshal data to it (at first it can be other proxies or
> simple data types.
> It might give us what we want.

If I may suggest a course of action:
* start small, get the simple things working first
* that pretty much means starting the work on a windows system so
that you can use the standard COM libraries there and you can focus on
the mono side of the development
* create a simple void Ping() client or server (whichever is easier to
implement) and then figure out what kind of support is needed in the
runtime to either expose the server or call out to the client.

Creating a little tarball with the code and a makefile to compile it
with the ms runtime will be helpful as a start, to see what kind of
support is needed (and how the metadata looks like for the COM cliet or

> Although I have a question.=20
> I will try to implement DCOM in C or C++ (I haven't decided yet), I
> persume I need to use some form of Platform Invoke to call this code,
> right?
> Can you point me out to a place where P/Invoke was used so I can check
> it out a bit?

Look into metadata/marshal.c, the mono_marshal_get_native_wrapper ()
function. Basically, when the JIT sees a call to a P/Invoke method m,
it calls:
	wrapper_method =3D mono_marshal_get_native_wrapper (m);

and wrapper method is called instead. The wrapper takes acre of the
need for marshaling values or different call conventions and so on.
I guess COM requires similar support.


lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better
Mono-list maillist  -  Mono-list@lists.ximian.com