Our porting work depends on having a link from C# to C++ using COM. This is a fundamental requirement, and without it we cannot proceed. Although we’ve had this working in small test programs for a long time, it would crash badly when we tried it with our application (WorldPad, part of FieldWorks). We were fairly sure it was something we were doing wrong, but could never pin it down. Well, now Tom and Brent have found the solution!
Language software for Linux and Mac OS X
The libcom COM Support Library version 0.4.0 has been released. This is the first release of libcom. libcom is licensed under the LGPL.
libcom implements a subset of Microsoft COM (Component Object Model) and supports both C++ and C# (via Mono) COM clients and servers on Linux. libcom is similar to ole32.dll in Windows.
libcom can be downloaded from http://linux.lsdev.sil.org/wiki/index.php/Downloads.
Update: libcom now has its own web page at http://linux.lsdev.sil.org/wiki/index.php/Libcom.
Recently we had a couple developers from other offices join us for LSDev Linux Brainstorming Week to learn from one another, talk about technology choices, and do some pair programming.
We were successful in making a C# application create a regular C# object and a C++ object (via libcom and RCW), pass the C# object to the C++ object, have the C++ object modify the C# object from native code, and then back in C# code observe that our C# object was indeed manipulated successfully from C++.
This capability to call back and forth between C# and C++ using COM is very important for porting several SIL programs to Linux, and we were concerned about whether it would even be possible with Mono. We found out several months ago that C# calling into C++ using libcom and Mono RCWs worked, and I was pleased to find that going the other direction, C++ calling C#, elegantly Just Works.
Eberhard and I largely reused existing libcom test code and just made some additions. The steps to perform this test and an explanation of what is happening can be found on our wiki here.
The core of SIL FieldWorks was written in C++. New development in FieldWorks is done in C#, and ties into the C++ core through COM.
After much looking all over the Internet in January 2005, I basically concluded that not only does no one use COM in Linux, but no one wanted to (outside of big enterprise application ports to UNIX).
When both porting FieldWorks to Linux and making it cross-platform, we lose access to Microsoft’s COM implementation in Windows. We were originally going to use SWIG to generate C# wrappers around the C++ core libraries. All C++ methods would then be P/Invoked, and COM would be bypassed.
Today I read the Mono 1.2 release notes. A few things stuck out to me:
- full implementation of 1.0 and 2.0 APIs
- full SWF 1.1 API
- MONO_IOMAP setting may help with some potential crossplatform issues
- Bundles. If our COM implementation ends up being rather Frankenstein (or really cutting-edge ), Bundles would let us distribute our own custom Mono along with the application. I don’t really see this as a desirable solution, but it’s nice to know it’s there.
- “Support for the registry is now provided on Linux and Windows.”