Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WIX: COM unregistration when removing one of two programs

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?

like image 554
madbadger Avatar asked Mar 21 '10 21:03

madbadger


2 Answers

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"

like image 137
Orion Edwards Avatar answered Sep 28 '22 05:09

Orion Edwards


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

like image 30
richb Avatar answered Sep 28 '22 04:09

richb