且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

调用C#.NET服务从C ++应用程序?

更新时间:2023-08-31 21:32:46

当然可以。您正在寻找.NET的一个功能叫做COM-互操作。

Absolutely. You're looking for a feature of .NET called COM-Interop.

http://msdn.microsoft。 COM / EN-US /库/ kew41ycz%28V = vs.71%29.aspx

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

第二个链接有一个ATL例子。

The second link has an ATL example.

编辑: 根据您的意见反馈,让我展开这...

Based on your feedback in the comments, let me expand on this...

嗯 - 你说得对页面上的样品

Ah - you're right about the sample on that page.

第一个链接是真的要开始的所有细节。如果你遵循的链接,你会发现这个页面:

The first link is really where you want to start for all the details. If you follow the links, you'll find this page:

揭露.NET框架组件以COM http://msdn.microsoft.com/en -us /库/ zsfww439%28V = vs.71%29.aspx

"Exposing .NET Framework Components to COM" http://msdn.microsoft.com/en-us/library/zsfww439%28v=vs.71%29.aspx

从本质上讲,它是在客户机上应用一系列的属性到类和属性,然后生成相应的注册表项(其中.NET有一个工具做的只是一个问题 - 见:的 http://msdn.microsoft.com/en-us/library/bctyca52 %28V = vs.71%29.aspx

Essentially, it's just a matter of applying a series of attributes to your classes and properties, and then generating the appropriate registry entries on the client machine (which .NET has a tool to do - see: http://msdn.microsoft.com/en-us/library/bctyca52%28v=vs.71%29.aspx)

我从VC打电话++和/或VB6需要.NET项目的人这样做了好几次自己。

I've done this several times myself for .NET projects people needed to call from VC++ and/or VB6.

其他一些链接可能会感兴趣的:

Some other links that might be of interest:

HTTP://www.$c$cproject.com/KB/ COM / nettocom.aspx < - 你正在尝试做的很好的例子

http://www.codeproject.com/KB/COM/nettocom.aspx <-- Perfect example of what you're trying to do.

HTTP://www.$c$cproject.com/KB/ COM / Universal_CCW.aspx