CLR \ CLI Com 对象 进程外服务器
如何将用托管 C++ 编写的 COM 对象注册为 SingleUse? Regasm 似乎没有这个选项。 我猜它可能就像在 AssemblyInfo.cpp 中定义属性一样简单,但我找不到它。
我编写了一个 VB6 ActiveX EXE,它按照我想要的方式工作 - 即对接口的每个请求都会创建一个新的运行服务器。
我是否必须将托管 C++ COM 封装在 VB6 中? 必须有一种更简单的方法。
How do you register a COM object written in Managed C++ to be SingleUse? Regasm does not appear to have the option. I am guessing it may be a s simple as defining an attribute in AssemblyInfo.cpp but I can't find it.
I have written a VB6 ActiveX EXE and it works as I want it to - that is every request for an Interface creates a new running Server.
Do I have to resort to wrapping my Managed C++ COM in VB6? There has to be an easier way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看来服务组件是解决我的问题的关键。
http://oreilly.com/catalog/comdotnetsvs/chapter/ch10.html
一旦我从 System.EnterpriseServices 命名空间中的 ServicedComponent 派生,就对 dll 执行 regsvcs,然后将 dcomcnfg 中的池更改为大于 1 - 一切正常。 另一个问题是使用 /clr:pure 而不仅仅是 /clr 来注册编译托管 C++ 组件。 我尚未完成该项目,但我以此方式构建的示例项目表明它应该以这种方式工作。 我想我会将我的托管 C++ 解决方案包装在 C# 程序集中...
现在我已经几乎完成了该项目,还有一件事...您需要在服务器操作系统上才能使池工作。
谢谢你的指导...
It looks like Serviced Components holds the key to my problem.
http://oreilly.com/catalog/comdotnetsvs/chapter/ch10.html
Once I derive from ServicedComponent in the System.EnterpriseServices namespace, do a regsvcs on the dll and then change the pooling in dcomcnfg to be greater than one - it all works. Another issue is to have the Managed C++ component being regsistered compiled with /clr:pure not just /clr. I have yet to complete the project but sample projects I built on the way indicate it should work this way. I think I will wrap my Managed C++ solution in a C# assembly...
Now that i have nearly finished the project one more thing...You need to be on a Server O\S to get the pooling to work.
Thanks for your guidance...
如何使用 Visual C++ 在 MFC 中使用 OLE 对象的单个或多个实例
http://support.microsoft .com/kb/141154
How to use single or multiple instances of an OLE object in MFC by using Visual C++
http://support.microsoft.com/kb/141154
这可能会给您一些线索:
使用托管控件作为 ActiveX 控件
http://blogs.msdn.com/andreww/archive/2008/11/24/using-management-controls-as-activex-controls.aspx
This might give you some clues:
Using Managed Controls as ActiveX Controls
http://blogs.msdn.com/andreww/archive/2008/11/24/using-managed-controls-as-activex-controls.aspx