It's not the end of the Internet, but you can see it from here.

Native Windows DotNet Interop

Today I learned a new way to use functionality from a DotNet assembly from a native Windows application.

Because I found the necessary information rather scattered over the internets, and it isn't explicitly mentioned in the Microsoft documentation, I publish a little demo solution.

http://springelkamp.nl/Files/Interop.zip

The standard documented way to call a DotNet class from native Windows code is to wrap the DotNet class in a COM object, and then manipulate the COM object from your native code.

I don't particularly like working with COM (my Windows experience come more from Delphi than from Visual Basic, so I could mostly avoid it) because of the installation and versioning issues.

The published demo uses a C++/CLI wrapper that exposes DotNet Methods as classic DLL exports.

In C++ compiled with the /clr option (using the MS C++ compiler) managed and native code can be mixed, using the IJW technology ('It Just Works').

In this way constructing a wrapper becomes quite trivial.

Now, if somebody would write a code generator to produce such a wrapper automatically....
Permalink Attila 
January 29th, 2010 1:36pm

This topic is archived. No further replies will be accepted.

Other topics: January, 2010 Other topics: January, 2010 Recent topics Recent topics