Log in

View Full Version : Calling Managed Code from Native Application


Kris Kumar
09-07-2005, 01:45 PM
<div class='os_post_top_link'><a href='http://blogs.msdn.com/windowsmobile/archive/2005/09/06/461805.aspx' target='_blank'>http://blogs.msdn.com/windowsmobile/archive/2005/09/06/461805.aspx</a><br /><br /></div><i>"A question that always pops up is "Can I call managed code from my native process?" And the answer was always "no". Sure, you could create a window and pass window messages between a native process and a managed process, but that's a pretty limited solution, and not a rich programming model. So I wrote a tool to let you do it. It's called Mirror and the source and binaries are available on <a href="http://windowsmobile.members.winisp.net/Interop.zip">http://windowsmobile.members.winisp.net/Interop.zip</a>. Here's how it works. You write a managed assembly that you want to be callable from native code. You'll have to restrict yourself somewhat when it comes to what language features you can use, because Mirror doesn't support everything. But it won't feel too constricting: you can use constructors, methods, properties and indexers. And as for what types you can pass around, you can use all the primitive types (ints, bools, etc.), along with strings and enums. You can even pass around instances of your own classes, as long as the classes themselves are Mirror-compatible."</i><br /><br />Jason Fuller has made the impossible possible. :-) If you are one of those developers who has the unique need to call into the managed code from the native code (C++), then Jason has a solution for you.