调用C#.NET服务从C ++应用程序? [英] Calling C# .NET Service From C++ Application?

查看:206
本文介绍了调用C#.NET服务从C ++应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个旧的MFC应用写在Visual Studio 6。这将在某个时候在C#.net被改写。不过,在此之前我必须写一些新的Windows服务,为现有的应用程序。其他人写的ATL。我将preFER做的是用C#.NET这些新的服务,这样,当应用程序的其余部分被重写,这些并不需要如此。

I have an old MFC app written in Visual Studio 6. This will at some point be rewritten in C# .NET. However, before then I have to write a couple of new Windows services for the existing application. The others were written in ATL. What I would prefer to do is write these new services in C# .NET so that when the rest of the application is rewritten, these don't need to be.

难道将是可以调用从旧的应用程序在.NET Windows服务托管库的接口?如果是的话,可以请你解释一下。

Is it going to be possible to call the interfaces on the libraries hosted in a .NET windows service from the old application? If so, could you please explain how.

推荐答案

当然可以。您正在寻找.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

这篇关于调用C#.NET服务从C ++应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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