COM Interop - COM Callable Wrappers
Support for Runtime Callable Wrappers (RCWs) has been in mono for a few months now. Support for COM Callable Wrappers (CCWs) is well underway. I have a patch pending, and am cleaning up some issues with it right now. CCWs basically allow you to safely expose managed objects to unmanaged code as COM objects.
I have to say the mono runtime is some cool code to hack around in; I also have to say thanks to the runtime hackers who continually help me out. Most of my time is spent translating the rules of a COM environment to the rules of the managed runtime. Essentially all of the technical functionality I need (getting a function pointer for a managed method, parameter marshalling, etc.) is already there. All I've had to do is implement some COM specific stuff in the runtime, and always remember to adhere to COM rules (AddRef the pointer returned from a QueryInterface call) and runtime rules when needed (don't hold onto an object pointer directly as that will cause big problems with the new moving garbage collector).
So what's left to do? Once the CCW patch gets in, not much from my point of view. I don't have support for IDispatch complete yet for either CCWs or RCWs, so that will get some attention. Beyond that it's bugs, performance, and what anyone requests (assuming someone will use this). And who would use this? I can think of a few cases:
I have to say the mono runtime is some cool code to hack around in; I also have to say thanks to the runtime hackers who continually help me out. Most of my time is spent translating the rules of a COM environment to the rules of the managed runtime. Essentially all of the technical functionality I need (getting a function pointer for a managed method, parameter marshalling, etc.) is already there. All I've had to do is implement some COM specific stuff in the runtime, and always remember to adhere to COM rules (AddRef the pointer returned from a QueryInterface call) and runtime rules when needed (don't hold onto an object pointer directly as that will cause big problems with the new moving garbage collector).
So what's left to do? Once the CCW patch gets in, not much from my point of view. I don't have support for IDispatch complete yet for either CCWs or RCWs, so that will get some attention. Beyond that it's bugs, performance, and what anyone requests (assuming someone will use this). And who would use this? I can think of a few cases:
- This may be a good way to interact with Mozilla/XPCOM components from mono. I haven't tried this yet as my skills at getting a working Mozilla build/development setup are not very good. My goal is either to get the System.Windows.Forms WebBrowser control working, or try to get the ASP.Net Designer to work using COM Interop to communicate with Mozilla.
- This may also be a good way to interact with Open Office. I think this has less potential than XPCOM, but I'm not ruling anything out yet.
- In general, it seems to be an ok way to wrap a C++ library if you don't want to use a C API created either manually or using one of the various tools available.
Labels: COM Interop, mono


6 Comments:
Hey!
Do you have an RSS feed that we could use? Currently your blog address as listed in monologue is Atom, which we do not handle.
Email me your RSS feed (Feedburner can be used to provide the translation).
Miguel.
One thing that might be useful would be to have an overview from your point of view of how your COM code works.
Am thinking a Wiki page on Mono-project.com would be useful. Maybe that way we could find some folks interested in providing bridges to OpenOffice UNO and Mozilla's XPCOM.
Miguel
Hello,
Is the current state of the mono COM interop allows accessing COM objects exposed in assemblies from C# ? I have already exposed our COM SDK library to .NET on Windows with TLBIMP.EXE.
thanks
-mab
Marc-Andre Belzile,
Yes, in most cases you should be able to use mono in that same manner as .Net. That's on windows only of course unless you port your COM SDK to Linux. Also, you can use IDispatch derived interfaces, but don't call any of the 4 IDispatch methods as they are currently not implemented. If you have any problems, let me know.
Thanks,
Jonathan
I am trying to get a application working on linux. Most of the source is compatible, except for the WebBrowser control.
I am getting the following error "The type or namespace name `WebBrowser' does not exist in the namespace `System.Windows.Forms'."
I am using Monodevelop 0.13 on suse linux. Any help on this regard would be great
Hey Jon,
Got anything working with Virtual Box ??
Want to control it from c#
Post a Comment
<< Home