如何在插件架构中完成免注册COM [英] How to do registration-free COM in a plug-in architecture

查看:260
本文介绍了如何在插件架构中完成免注册COM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用清单文件做无注册COM,我也在此其他问题

We use manifest files to do registration-free COM, as I've also elaborated on in this other question.

现在我们试图使用免注册COM与支持插件的应用程序。插件是OCX文件,可以在主应用程序已安装后添加到主应用程序的文件夹。

Now we're trying to use registration-free COM with an application that supports plug-ins. The plug-ins are OCX files that can be added to the main application's folder after the main application is already installed.

但是,这意味着主应用程序的清单文件需要由插件安装程序修补。这似乎是一个危险的和容易出错的事情,特别是如果可以安装多个插件。

However, that means that the manifest file of the main application would need to be patched by the plug-in installer. That seems like a dangerous and error-prone thing to do, especially if multiple plug-ins can be installed.

有一种方法以某种方式拆分的清单文件主应用程序,以便每个插件可以安全地添加自己的部分作为一个单独的文件?

Is there a way to somehow split the manifest file of the main application, so that each plug-in can safely add it's own part as a separate file? Or another safe way to patch the manifest file?

如果是相关的:我们使用 wix

In case it is relevant: we create our installers with wix.

推荐答案

我不建议修改清单文件应用程序;

I wouldn't recommend modifying the manifest file of the application; that seems fairly fragile and would only work if it lives in a writeable location.

在进程启动时,应用程序的清单用于生成一个激活上下文,该激活上下文是推送为过程范围的激活上下文。但每个线程也有一个激活上下文堆栈,可以直接操作。在查找COM注册数据时,给定线程的操作查看堆栈上的最顶层上下文和进程范围的激活上下文。

At process startup, an application's manifest is used to generate an "activation-context" which is pushed as the process-wide activation context. But each thread also has an activation-context stack, which can be directly manipulated. Operations on a given thread look both at the topmost context on the stack and the process-wide activation context when looking for COM registration data.

建议任何时间的插件代码需要调用到COM,一个插件特定的清单应该在线程上激活。这可以通过以下两种方式之一轻松完成:

The recommendation is that any time plugin code needs to call into COM, a plugin-specific manifest should be activated on the thread. This can most easily be done in one of two ways:


  1. 将插件特定的清单作为ID2清单嵌入插件并使用宏 ISOLATION_AWARE_ENABLED

激活/取消激活正确的激活上下文在线程周围的所有入口点进入插件。这是通过激活上下文API 完成的。通过激活上下文管理对象 a>。

Activate/Deactivate the proper activation context on the thread around all the entry points into the plugin. This is done through the activation context APIs. This is most easily done with an activation context management object.

这篇关于如何在插件架构中完成免注册COM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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