4
votes

Problem:

I have made a Windows Service i VS2010 (C#) and a corresponding .msi that installs and starts it. Version, ProductCode, UpgradeCode etc. is set properly. RemovePreviousVersions is set to true. Works fine.

Now I want to make a new version of the service, and I want the updated .msi to update the service without requireing the user to manually uninstall the old service first.

What I do is this:

  1. I update the the source code of my service
  2. In the .msi project I change the version number and ProductCode (while leaving the UpgradeCode unchanged)
  3. I rebuild the whole thing.

But, when I afterwards launch the updated .msi, it fails with the following message: "Error 1001. .... An instance of the service is already running".

Questions:

  • Why is the service not automatically uinstalled before installing the updated version?

  • What can I do to make it work?

1
Stop the service running. (net stop servicename should test if that is the issue)Anirudh Ramanathan
That dosn't help much. Then I just get "Error 1001. The specified service already exists". Note: If I manually uninstall the application (from add/remove programs in control panel) the service stops and uninstalls all right.Martin Christiansen
There were several changes to service configuration added in MSI v5.0. You might want to take a look at Using Services Configuration in the MSDN documentation. I can't recall whether these would address an issue like yours.Mark Rovetta
Did you assured that the previous version uninstalled during upgrade? If not, than in this case, you trying install new version on existing - it could cause the similar errors.Igor Shenderchuk

1 Answers

1
votes

The changes from Windows Installer 5.0 are not of interest for this situation, they refer to failure configurations.

Since uninstalling the application manually from Control Panel removes the service it is clear the install of the new version does not remove the previous one. To inspect why you need to create a verbose log and check for RemoveExistentProducts standard action. To create a log use this command

msiexec /i {msi path} /l*v file.log

You should know that you must change one of the first three version numbers to make sure the OS considers the new package an upgrade, the forth is ignored. Also, you should make sure the packages have the same installation type, i.e. per user or per machine. If the install types differs the upgrade is skipped.