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

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

问题描述

我有一个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)

如果同时设置了install和 卸载自定义操作 应用程序的安装项目,而您 已启用 中的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中,卸载 不调用操作,如下所示:

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

放入通过使用Orca将InstallExecuteSequence.RemoveExistingProducts更改为.InstallInitialize之后,VS2008的行为又回到了它在VS2005中的工作方式(旧版本的卸载自定义操作在新版本的Install之前被调用).通常,您将.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天全站免登陆