Alan Baljeu
Alan Baljeu

Reputation: 2443

How to migrate from C++ COM to C++CLI

I have a C++ DLL that exposes stuff via COM. I want to convert it to C++/CLI that exposes a managed interface. Ideally I just add CLI and convert interfaces one by one. So far I haven't succeeded in anything, so I'm looking for a specific strategy.


More detail: A long time ago, I created an app using COM to communicate back and forth between C# and C++. I'm sick of COM, and the registration and the hoop jumping needed on the C++ side.

I want to use C++/CLI, and get the whole thing working as managed code with the occasional call from C++/CLI to native libraries I'm using.

Can anyone suggest a gentle migration path, such that I can have both CLI and COM going, and convert things over class by class testing as I go? Or something like that.

To be clear: I currently have native C++ code defining and implementing COM interfaces. I have C# code using COM attributes to export classes. All this stuff gets registered for COM interop, and there are calls in both directions. I hope to switch the C++ to CLI and switch to managed classes in C++ rather than COM classes.

Question updated for Ramhound: Anyway, I'm running into brick walls. Turning on /clr on a C++ dll gives me link errors from other stuff trying to connect to that C++ code. (Unreadable ATL/COM messages of the sort that drive me away from C++)

Upvotes: 3

Views: 474

Answers (2)

David
David

Reputation: 87

You may want to read through this, as it provides some different approaches and considerations involved: http://msdn.microsoft.com/en-us/magazine/dd315414.aspx

Here is a simple example of how to use interop in C++/CLI, where you could define a method or two and add more as you go: https://learn.microsoft.com/en-us/archive/blogs/borisj/interop-101-part-1

Upvotes: 2

cealex
cealex

Reputation: 1

please follow this

http://msdn.microsoft.com/en-us/magazine/cc163494.aspx

use tlimp to generate a COM unmanaged DLL to a managed DLL

is pretty simple!!!

Upvotes: -1

Related Questions