如何消除“指定的服务已经存在"?当我安装新版本的软件时? [英] How do I eliminate "The specified service already exists" when I install new versions of my software?

查看:17
本文介绍了如何消除“指定的服务已经存在"?当我安装新版本的软件时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 VS2008 应用程序,其中包含一个服务项目(我将其称为 ServiceProject).我将安装项目 (InstallationProject) 设置为 RemovePreviousVersions.此外,我为 InstallationProject 设置了自定义操作,用于安装、提交、回滚和卸载 ServiceProject 的主要输出.

I have a VS2008 application that includes a service project (I'll call it ServiceProject). I have the installation project (InstallationProject) set to RemovePreviousVersions. Additionally, I have Custom Actions set for InstallationProject, to Install, Commit, Rollback, and Uninstall the Primary output from ServiceProject.

有时当我构建新版本的安装程序时,我可以安装而不会出错.通常,当我开始设置服务(在安装程序中输入用户名和密码)时 - 它会失败并显示错误,指定的服务已经存在".

Sometimes when I build new versions of the installer, I can install without an error. Often, when I get to the point of setting up the service (entering a username and password into the installer) - it fails with the error, "The specified service already exists".

我不知道为什么会不一致,尽管我考虑过该服务可能存在某种签名,如果该服务未修改,则可以成功删除它,但是经过修改,它不会'不承认服务.但是,我很少对服务进行修改,所以我怀疑就是这样.

I don't know why it's inconsistent, though I've considered that maybe there is some kind of signature for the service and if the service is unmodified, it is able to remove it successfully, but with modifications, it doesn't recognize the service. However, I rarely make modifications to the service, so I doubt that's it.

如何让我的安装程序成功更新服务而不出现此错误?我的解决方法是手动进入控制面板,卸载之前的应用程序,然后运行安装程序.

How can I make my installer successfully update the service without this error? My work-around is to manually go into Control Panel, uninstall the former application, then run the installer.

推荐答案

除了确保文件版本不同之外,StingyJack 提到您还有另一个问题.来自 VS 文档(抱歉,不是在线的)

In addition to making sure the file versions are different as StingyJack mentioned you have another problem. From the VS documentation (sorry, not online)

如果您同时设置了安装和卸载自定义操作应用程序的安装项目,你已启用RemovePreviousVersions 属性在Visual Studio 2005,以前的产品版本已卸载在升级过程中.然而,这Visual Studio 2008 中的行为已更改如下:

If you have set both install and uninstall custom actions in an application's setup project, and you have enabled the RemovePreviousVersions property in Visual Studio 2005, the previous version of the product is uninstalled during an upgrade. However, this behavior changed in Visual Studio 2008 as follows:

在 Visual Studio 2005 中,自定义动作被调用如下从 v1.0.0 升级到 v1.0.1:

In Visual Studio 2005, the custom actions were called as follows on an upgrade from v1.0.0 to v1.0.1:

v1.0.0 自定义操作 Uninstall()

v1.0.0 custom action Uninstall()

v1.0.1 自定义操作 Install()

v1.0.1 custom action Install()

在 Visual Studio 2008 中,卸载没有调用action,如下:

In Visual Studio 2008, the uninstall action is not called, as follows:

v1.0.1 自定义操作 Install()

v1.0.1 custom action Install()

如果您创建自定义操作依赖在旧的行为上,你需要修改新行为的代码.此行为更改仅影响更新,而不是卸载.

If you created custom actions relying on the old behavior, you need to modify your code for the new behavior. This behavior change affects only updates, not uninstalls.

因此,您正在使用自定义操作安装服务 - 但是升级时卸载部分并未按预期调用,并且您尝试在现有的运行版本上进行安装.

So you are installing a service using a custom action - but when upgrading the Uninstall part is not being called as you expect and you are trying to Install over an existing, running version.

认为要求重启是因为它在运行时无法更新服务文件.

I think that when its asking for a reboot is because it can't update the services file whilst its running.

两个选项:-

将代码添加到您的安装/提交自定义操作以停止服务,等待安装程序替换服务文件,然后重新启动服务.请参阅 PonalSuper3 对此的回答线程

Add code to your Install/Commit custom action to Stop the service, wait for the installer to replace the services files and then restart the service. See PonalSuper3's answer in this thread

把VS2008 行为回到它在 VS2005 中的工作方式(旧版本卸载自定义操作在新版本安装之前调用),通过使用 Orca 将 InstallExecuteSequence.RemoveExistingProducts 更改为紧跟在 .InstallInitialize 之后 - 通常您设置 .RemoveExistingProducts到 1525,但请检查您的个人 MSI.

Put the VS2008 behaviour back to how it worked in VS2005 (the old versions Uninstall custom action is called before the new version Install) by using Orca to alter the InstallExecuteSequence.RemoveExistingProducts to be immediately after .InstallInitialize - usually you set the .RemoveExistingProducts to 1525 but check your individual MSI.

我添加了一个 脚本,您可以添加到您的构建过程以更改 MSI 的 InstallExecuteSequence

这篇关于如何消除“指定的服务已经存在"?当我安装新版本的软件时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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