[Mono-list] Good Mono Project

Jonathan Pryor jonpryor@vt.edu
Fri, 18 Mar 2005 07:03:25 -0500

On Fri, 2005-03-18 at 22:33 +1300, Ralph Mason wrote:
> Seems to me that one can easily do a layer to create the com 'controls' 
> (eg the standard ones provided) on top of WIndows.Forms.  Com controls 
> are supported under windows.

Mono doesn't currently support COM controls anywhere.

> I can't imagine it's that hard to load a 
> shared library and provide the 3 or 4 functions you need to make a com 
> control work, and the standard interop stuff provided in the CLR should 
> make calling those functions a snap.

Yes, only 3 or 4 functions...  Let's look at those functions:

DllRegisterServer() and DllUnregisterServer() are supposed to insert the
COM object into the Registry.  This requires Win32 Registry function
support.  (If you don't support the Win32 registry functions, no
existing COM object code will work, requiring developers to re-write
their code, which won't happen, eliminating the whole point of COM

DllCanUnloadNow() is easy enough to support.

DllGetClassObject() is also easy enough to support...  Except for
defining a COM interface layout (use GCC's __attribute__
((com_interface))?), and the implementation of the COM object (which
will likely require support for more Win32 functions such as
InterlockedIncrement() and InterlockedDecrement() if the COM object is

Then there's the semantics of COM, such as the various apartment models.

COM is love, COM is simple ("as simple as possible, but no simpler"),
COM is great, but it isn't portable, and it was never intended to be.
COM object lookup is intimately tied into the Registry, the
implementation of most (all?) COM objects will require Win32 anyway, and
some COM apartment models require a Windows Message Loop.  It's very
difficult to remove COM from Win32 (it can be done; see Mozilla's
XPCOM), and if you want to maintain *any* compatibility with existing
COM objects, you need Win32.

If you don't care for maintaining Win32 support, then why are you
bothering with COM in the first place?  Just re-write in Mono, you'll
need to re-write anyway...

COM support is much more than just supporting 4 DLL exports.  At least,
it's much more than those 4 exports if you want it to mean anything.

 - Jon (who's done some COM programming...)