WIX:删除两个程序之一时 COM 注销

发布于 2024-08-25 14:41:33 字数 767 浏览 4 评论 0原文

我对 WiX 还比较陌生。这是一个很棒的工具,但我还需要一些时间 为了更好地学习它。 我在注册和取消注册 COM 时遇到问题 成分。我已经为两个应用程序创建了安装程序,我们称它们为 A 和 B. 两者都使用相同的 COM 组件。我已经使用了加热工具,如 受到推崇的。安装A或B时,组件注册时没有任何 问题。

但是当我安装 A 和 B,然后删除 A(使用添加/删除程序)时,COM 类被取消注册,B 不能再使用它。有没有干净的 解决方案来防止这种情况发生?我想取消注册 COM 当 A 和 B 都被卸载时。

任何帮助将不胜感激,

最诚挚的问候, madbadger

编辑:感谢您的回复。我在两个安装程序中将 GUID 设置为相同的值,现在注册表项已正确删除,即从系统中删除最后一个程序时。
然而,由于一个原因,这个问题仍然存在。我已经检查了 HKEY_CLASSES_ROOT/CLSID/[适当的 COM GUID] 下的注册表。发生的事情是这样的:
- 我安装 A 并将 COM 的路径设置为 [A/component.dll 的路径]
- 我安装 B 并将 COM 的路径设置为 [B/component.dll 的路径]
- 我删除了 B,COM 的路径仍然是 [B/component.dll 的路径]
- 现在 A 无法访问 COM 组件,尽管它已注册,因为 [B/component.dll 的路径] 不再存在

现在我认为必须将 COM 组件放在两个应用程序的同一目录中。 Windows Installer 是否无法恢复到旧路径,或者是我遗漏了什么?

I am relatively new to WiX. It is a great tool, but I still need some time
to learn it better.
I have encountered a problem with registration and unregistration of a COM
component. I have created installers for two applications, lets call them A
and B. Both are using the same COM component. I have used the heat tool, as
recommended. When installing A or B, the component is registered without any
problems.

But when I install A and B, then remove A (with Add/Remove programs) the COM
class gets unregistered and B cannot use it anymore. Is there a clean
solution to prevent this from happening? I would like to unregister the COM
when BOTH A and B are uninstalled.

Any help would be appreciated,

Best regards,
madbadger

EDIT: Thanks for your responses. I set the GUID to the same value in the both installers and now the registry keys are being removed properly, that is when the last program is removed from system.
Hovewer, the problem persists for one reason. I have checked the registry under HKEY_CLASSES_ROOT/CLSID/[appropriate COM GUID]. This is what happens:
- I install A and the path to COM is set to [path to A/component.dll]
- I install B and the path to COM is set to [path to B/component.dll]
- I remove B and the path to COM remains [path to B/component.dll]
- Now A cannot access the COM component althrough it is registered, because [path to B/component.dll] does not exist anymore

Now I assume it is obligatory to put the COM component in the same directory for both applications. Is Windows Installer not able to revert to the old path, or is it something I am missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝色星空 2024-09-01 14:41:33

Windows 安装程序将为您执行此操作,但前提是您的 COM 组件在 A 和 B 上具有相同的 GUID,(并且两个应用程序将 dll 安装在同一位置。)

Windows 安装程序可以正常工作通过对每个组件(整个系统)进行引用计数。组件通过其 GUID 进行标识。

如果 COM 组件具有相同的 GUID,则会发生以下情况:

  • 安装 A:组件引用计数从 0->1,Windows 安装程序注册它
  • 安装 B:组件引用计数从 1->2,没有任何反应
  • 卸载 A:组件引用计数从 2->1,没有任何反应
  • 卸载 B:组件引用计数从 1->0,Windows 安装程序取消注册它

如果它没有相同的 GUID,会发生这样的情况

  • 安装 A:组件 A 引用计数从0->1,Windows 安装程序注册它
  • 安装 B:组件 B 引用计数从 0->1,Windows 安装程序注册它,覆盖组件 A 的注册表项。
  • 卸载 A:组件 A 引用计数从 1->0, Windows 安装程序会取消注册它,删除注册表项。
    -- 看来这就是您在
  • 卸载 B 中的情况:组件 B 引用计数从 1->0,Windows 安装程序取消注册它,删除注册表项(但它们已经被删除)

编辑评论:

除了 GUID 之外,每个组件还有一个“关键路径”。如果组件包含一个或多个文件,则应使用 KeyPath="foo.dll" 设置哪个文件是“Key”文件。如果该组件包含一个或多个注册表项,则情况类似。

当检查是否安装了某些东西时,Windows安装程序将检查GUID,读取关键路径,然后检查关键路径处的文件(这就是它如何确定东西是什么版本等),所以如果2个组件有相同的 GUID,它们必须还具有相同的密钥路径,该路径必须在安装产品时解析到文件系统中的相同位置。

这是一种冗长的说法,表示两个安装程序必须将共享文件放在同一位置。至于把它们放在哪里,System32 不是一个好地方。

我建议在公共文件文件夹下的某个位置(通常是 Program Files\Common Files\YourCompanyName)。您可以在 Wix 中输入如下内容:Directory="[CommonFilesFolder]\YourCompanyName"

The windows installer will do this for you, but only if your COM component has the same GUID across both A and B, (and the dll's are installed in the same place by both applications.)

Windows installer works by reference-counting each component (across the whole system). Components are identified by their GUID's.

If the COM component has the same GUID, what happens is this:

  • Install A: Component refcount goes from 0->1, windows installer registers it
  • Install B: Component refcount goes from 1->2, nothing happens
  • Uninstall A: Component refcount goes from 2->1, nothing happens
  • Uninstall B: Component refcount goes from 1->0, windows installer unregisters it

If it doesn't have the same GUID, what happens is this

  • Install A: Component A refcount goes from 0->1, windows installer registers it
  • Install B: Component B refcount goes from 0->1, windows installer registers it, overwriting registry entries from component A.
  • Uninstall A: Component A refcount goes from 1->0, windows installer unregisters it, deleting registry entries.
    -- It appears as though this is the situation you're in
  • Uninstall B: Component B refcount goes from 1->0, windows installer unregisters it, deleting registry entries (but they're already deleted)

Edit Uplifted from comments:

As well as the GUID, each component also has a "Key Path". If the component contains one or more files, you should set which file is the "Key" file using KeyPath="foo.dll". If the component contains one or more registry entries, it's similar.

When checking if something is installed, the windows installer will check the GUID, read the key path, then check the file at the key path (this is how it figures out what version things are, amongst other things), so if 2 components have the same GUID, they must also have the same key path, which must resolve to the same place in the file system when the product is installed.

This is a longwinded way of saying both installers must put the shared files in the same place. As for where to put them, System32 is NOT a good place.

I'd suggest somewhere under the common files folder (usually Program Files\Common Files\YourCompanyName). You'd enter this in Wix like so: Directory="[CommonFilesFolder]\YourCompanyName"

多情癖 2024-09-01 14:41:33

在您的组件标签中,您是否在每个安装程序中使用相同的 Guid?

In your Component tag, are you using the same Guid in each installer?

掀纱窥君容 2024-09-01 14:41:33

您应该将这个通用组件包装在合并模块中,并从两个应用程序中引用它。

这将自动让共享 dll 引用计数在卸载时完成其工作。

You should wrap this common component in merge module and reference it from both your apps.

This will automagically let the shared dlls refcounting do its job on uninstall.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文