How to do registration-free COM in a plug-in architecture

前端 未结 2 1306
庸人自扰
庸人自扰 2021-02-08 19:49

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

Now we\'re trying to use registration-free COM with an app

相关标签:
2条回答
  • 2021-02-08 20:12

    If you're using .Net, you can use the code shown in this answer to take care of the activation contexts.

    0 讨论(0)
  • 2021-02-08 20:17

    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.

    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.

    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. Embed the plugin-specific manifest as an ID2 manifest into the plugin and compile with the macro ISOLATION_AWARE_ENABLED defined. This basically wraps common Windows APIs that need context from a manifest to automatically activate and deactivate the proper activation context around the call.

    2. 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.

    0 讨论(0)
提交回复
热议问题