Monday, February 26, 2007

Three COM Interop Updates

COM Callable Wrappers

First, COM Callable Wrapper support is now in svn. This means that managed objects can be passed to C++ and interacted with as if they were unmanaged COM objects. It still needs some more work, but most basic use of this functionality should work.

User Base Doubles

Previously, I seemed to be the only person interested in using COM Interop, especially on Linux. However, I had an exchange with someone on IRC last week who is trying to port their C#/C++ COM application from Windows to Linux. They are investigating using COM Interop instead of having to write a C wrapper layer with pinvokes.

Mozilla/XPCOM

Theoretically, the COM Interop functionality should work with Mozilla/XPCOM or any COM like system at least on Windows and Linux on x86 and x86-64 architectures (COM Interop depends on the binary layout of vtables). I always planned on trying COM Interop on XPCOM but never had the time. This weekend I took an hour or so and tried to hack something together. Since Monodevelop has an ASP.Net designer that uses Mozilla and one of the future goals is better DOM access, I decided to hack something together inside of the editor.

The good news is that it works! I can traverse/access the DOM without any glue/wrapper library. I just need to define some interfaces in C# and get a pointer to the DOM. The bad news is that strings in Mozilla/XPCOM really stink. I couldn't figure out how to marshal the strings correctly, thus making the exercise less than complete. If anyone knows what a DOMString is, please post a comment. If it ends up being a fairly simple type it can be marshalled that would be great, however if it's just a C++ class (as I currently fear) some unmanaged glue code will be needed to convert the string to something usable by the marshaller.

Labels: ,

4 Comments:

Anonymous Chris said...

Great news! While I have used JSCall quite a bit (and actually submitted a patch) it will be great when we can access the DOM without glue libraries.

2:43 PM  
Blogger Michael Hutchinson said...

Fantastic! I'd love to be able to eliminate unmanaged glue and have proper DOM access.

You're right about strings being a complete mess in Mozilla. There are also now frozen and unfrozen/internal versions of string headers, and macros and templates dotted around the place too.

If you haven't seen them already, I *think* the places to look are the XPCOM string guide and the string embedders' API. It might also be worth looking at MonoConnect or JavaXPCOM to see if/how they handle strings, or asking on the Mozilla embedding mailing lists.

7:12 AM  
Blogger ianire said...

oh my God!
I am trying to incorporate prolog in .aspx and executing it with mono ( xsp) it appears a horrible error:

amzinet.dll contains native code and mono can`t run it. The assembly was probably created by Managed C++.

Any solution please?
Looking forward to hearing fron you,

TABU.

9:30 AM  
Blogger ianire said...

oh my God!
I am trying to incorporate prolog in .aspx and executing it with mono ( xsp) it appears a horrible error:

amzinet.dll contains native code and mono can`t run it. The assembly was probably created by Managed C++.

Any solution please?
Looking forward to hearing fron you,

TABU.

9:30 AM  

Post a Comment

<< Home