如何从C ++ COM迁移到C ++ CLI [英] How to migrate from C++ COM to C++CLI

查看:176
本文介绍了如何从C ++ COM迁移到C ++ CLI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++ DLL通过COM暴露的东西。我想将其转换为暴露受管接口的C ++ / CLI。理想情况下,我只需添加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.

更多细节:
很久以前,我创建了一个应用程序使用COM在C#和C ++之间来回通信。我对COM感到不舒服,并且在C ++端需要注册和跳跃。

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.

我想使用C ++ / CLI,让整个事情工作托管代码与从C ++ / CLI到我正在使用的本机库的偶尔调用。

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.

任何人都可以建议一个温和的迁移路径,这样我可以有CLI和COM在我去的时候,通过类测试将事物转换成类?或者类似的东西。

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.

要清楚:我目前有本地C ++代码定义和实现COM接口。我有C#代码使用COM属性导出类。所有这些东西都注册COM互操作,并有两个方向的呼叫。我希望将C ++切换到CLI,并切换到C ++中的托管类,而不是COM类。

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.

问题更新为Ramhound:无论如何,我跑进砖墙。打开/ clr在C + + DLL给我来自其他尝试连接到该C ++代码的东西的链接错误。 (不可读的ATL / COM消息,驱使我远离C ++)

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++)

推荐答案

您可能需要通读,它提供了一些不同的方法和注意事项: http://msdn.microsoft.com/ en-us / magazine / dd315414.aspx

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

下面是一个简单的例子,说明如何在C ++ / CLI中使用interop,两个并添加更多: http:// blogs .msdn.com / b / borisj / archive / 2006/07/29 / 683061.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: http://blogs.msdn.com/b/borisj/archive/2006/07/29/683061.aspx

这篇关于如何从C ++ COM迁移到C ++ CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆