使用特定的 dll 版本调用 COleDispatchDriver::CreateDispatch
我有一些 MFC6 项目和一个用 DotNet 4 编写的项目。MFC 项目和 .Net 项目之间的通信是通过 COM 进行的,COM 服务器位于 .Net 端。 COM 服务器通过 RagAsm.exe 注册。在 MFC 中,我创建此 COM 服务器的实例,如下所示:
CreateDispatch( _T("PROGID.namespace") )
问题是,COM 服务器由不同的项目使用。因此,如果我想由于代码更改而增加 com 服务器 dll 的版本号,我必须使用 RegAsm 再次注册它。现在我的注册表中有这个 dll 的两个版本。但是当我调用 CreateDispatch 方法时,程序每次都会尝试加载最新的。这意味着,包含旧版本的项目将无法找到正确的 dll。调用 CreateDispatch() 时似乎无法指定版本。
还有另一种可能性可以解决这个问题吗?
I have some projects in MFC6 and one project which is written in DotNet 4. The communication between the MFC projects and the .Net project is via COM and the COM Server is on .Net side. The COM server is registered via RagAsm.exe. In MFC I create an Instance of this COM Server like this:
CreateDispatch( _T("PROGID.namespace") )
The problem is, that the COM Server is used by different projects. So if I want to increase the version number of my com server dll due to code changes, I had to register it again with RegAsm. Now there are two versions of this dll in my registry. But when I call the CreateDispatch method, the program everytime tries to load the newest one. That means, that the projects, which include the older versions, won't be able to find the correct dll. It seems it is not possible to specify a version when calling CreateDispatch().
Is there another posibility to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ProgID
将解析为CLSID
,然后最终解析为 COM 服务器二进制文件。如果您希望系统中存在两个不同的 COM 服务器,为什么不使用“版本相关”(而不是您在上面的代码片段中使用的版本无关)ProgID
的有不同的版本。ProgID
would resolve intoCLSID
and then eventually to COM server binary. If you would like to have two different COM servers present in the system, why don't you use "version-dependent" (as opposed to version independent you used in your code fragment above)ProgID
's with different versions.