使用Windows Installer取消Windows服务安装/卸载会导致服务未完全安装/卸载 [英] Cancelling a Windows service installation/Uninstallation with the Windows Installer causes service to be incompletely installed/uninstalled

查看:329
本文介绍了使用Windows Installer取消Windows服务安装/卸载会导致服务未完全安装/卸载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用VS 2017为Windows服务创建了WindowsInstaller.WindowsService中具有项目安装程序和服务安装程序类.当我在中途取消卸载过程时,该过程会删除Windows服务,但不会更新数据,因此,下次我运行安装程序时,可以选择修复或卸载Windows服务".现在,尝试卸载Windows服务会显示错误消息指定的服务不存在",因此卸载过程会回滚.现在,系统处于无法安装或卸载服务的状态.为了能够完全删除该服务,必须从命令行再次安装该服务,以便可以正确地将其卸载.有没有解决这个问题的方法?我想到了使用服务安装表来确保即使在取消时也已正确删除了服务,但是当我尝试安装服务时,我得到一个错误消息,即已经安装了服务[Project Installer/Service Installer类执行此安装,我认为]

I have created a Windows Installer for a windows service with VS 2017. The windows service has a project installer and service installer class inside it. When I cancel the uninstallation process midway, the process removes the windows service but does not update data, so the next time I run the setup , I get the option to Repair or Uninstall the windows service. Attempting to uninstall the windows service now gives an error that "the specified service does not exist", and hence the uninstall process rolls back. Now the system is in a state where the service can neither be installed nor uninstalled. To be able to remove the service completely, it must be installed once again from the command line, so that it can be properly uninstalled. Is there a way around this issue? I thought of using the service install table to make sure that the service is properly removed even on cancel, but then I get the error that service is already installed when trying to install the service [The Project Installer/Service Installer classes do this installation, I think]

推荐答案

首先请确保您已完成所有自定义操作服务安装程序节点,尤其是已填充提交"和回滚"节点自定义操作.这些自定义操作都可以一起使用,因此,如果您错过了其中一个可能会导致问题的操作.从理论上讲,取消卸载应注意不再安装该服务,而应重新安装.

First make sure that you've done all the custom action service installer nodes, in particular have the Commit and Rollback node custom actions populated. These custom actions all work together, so if you have missed one of them that could cause the problem. In theory, canceling the uninstall should have noted that the service is no longer installed, and it should be re-installed.

如果这不是问题,则可能是一个错误.修复此问题最有用的方法是在调用base.Uninstall()之前覆盖安装程序类中的base.Uninstall()并添加一些代码以检查该服务是否已实际安装.

If that's not the issue, then it's probably a bug. The most useful thing you can do to fix it is to override base.Uninstall() in the installer class and add some code to check the service is actually installed before calling base.Uninstall().

Visual Studio安装程序项目是唯一使用代码安装服务的项目,它们是调用安装程序类方法的自定义操作.其他所有人都使用Windows Installer提供的ServiceInstall和ServiceControl表.

Visual Studio setup projects are the only ones that use code to install services, and they are custom actions to call installer class methods. Everyone else uses the ServiceInstall and ServiceControl tables supplied by Windows Installer.

如果您不想完全切换到其他工具(例如WiX),可以使用一些选项:

Some of the options you can use if you don't want to completely switch to another tool such as WiX are:

  1. 如果您对服务有所了解,则ServiceControl和ServiceInstall表不会太复杂.如果您从此处向下滚动到有关Visual Studio的段落并安装服务,则会有一篇文章和一个程序可以帮助您解决此问题:

http://www.installsite.org/pages/en/msi/tips.htm

  1. 您可以深入研究WiX,以创建一个合并模块,该模块将安装服务以及所需的任何启动/停止操作.然后将该合并模块合并到您的Visual Studio安装程序中.不需要自定义操作(安装类是自定义操作,因此您不需要它们).

这篇关于使用Windows Installer取消Windows服务安装/卸载会导致服务未完全安装/卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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