问题由安装程序类停止Windows服务。事件引发为时已晚为时已晚、安装程序、事件、问题

2023-09-03 20:39:57 作者:彈指間的青春

我在使用Visual Studio 2010与.NET 4.0。 我有一个从一个Visual Studio安装项目安装Windows服务。在设置项目中,我有删除previousVersion属性设置为True。

I'm using Visual Studio 2010 with .NET 4.0. I have a windows service that is installed from a Visual Studio Setup Project. In the setup project I have the RemovePreviousVersion property set to True.

在包含服务我从previous版本升级时,将用于停止该服务的安装程序类的项目。

In the project that contains the service I have an installer class that will be used to stop the service when upgrading from a previous version.

所以升级软件时,服务将已经存在,可以运行。如果在安装过程中,然后运行安装程序会提示该文件已在使用,并给出再试一次,继续或退出安装的选项。在这个阶段,我可以手动停止该服务,然后单击再试一次,这将正常工作。但我不希望最终用户必须做到这一点。

So when upgrading the software the service will already exist and could be running. If it is running then during the installation the installer prompts that the file is already in use and gives the option to Try Again, Continue or Exit Installation. At this stage I could stop the service manually and click Try Again and this will work. But I don't want the end user to have to do this.

我已经把消息框的整个安装程序类BeforeInstall,BeforeUninstall(安装程序的事件),安装,卸载,提交,回滚(覆盖方法),这样我就可以看到这些时,在安装过程中被调用。

I have put messagebox's throughout the installer class BeforeInstall, BeforeUninstall (installer events), Install, Uninstall, Commit, Rollback (overridden methods) so I can see when these are called during the installation.

在安装运行的提示该文件正在使用在任何的安装程序类code显示。一旦我停止该服务,然后点击重试是会继续下去,在Me​​ssageBox在安装类将被显示出来。因此,安装程序类是肯定被调用它的过程中只是来不及其实做任何事情。

When the install is run the prompt that the file is in use is displayed before any of the installer class code. Once I stop the service and click try again is will continue and the messagebox's in the install classes will be displayed. So the installer class is definately being called it's just too late in the process to actually do anything.

我不认为这是在早期版本的.NET的行为?

I don't think this was the behaviour in earlier versions of .NET?

有没有人遇到过这个问题,或者有什么建议?

Has anyone come across this problem or have any suggestions?

我可以试试InstallShiled LE项目随Visual Studio 2010中,如果我需要(不知道这会产生相同的结果),但将preFER,看是否有人知道与Visual Studio安装项目的解决方案如果可能的话。

I could try the InstallShiled LE Project that comes with Visual Studio 2010 if I needed to (not sure if that would give the same result) but would prefer to see if anyone knows a solution with the Visual Studio Setup Project if possible.

推荐答案

的重试信息显示由FilesInUse安装对话框。在 InstallValidate 的行动Windows安装程序会自动检测正在使用的文件,并提示用户他们。

The try again message is shown by FilesInUse installer dialog. During InstallValidate action Windows Installer automatically detects files in use and prompts the user about them.

一个解决方案是停止(不删除)InstallValidate操作前的服务。这可以通过自定义动作来完成。

A solution is to stop (without removing) the service before InstallValidate action. This can be done through a custom action.

请注意,您不能设置InstallValidate前自定义操作与Visual Studio。但是,您可以编辑MSI与奥卡它生成后的变化在InstallExecuteSequence表中的动作顺序。

Please note that you cannot set a custom action before InstallValidate with Visual Studio. However, you can edit the MSI with Orca after it's generated and change the action sequence in InstallExecuteSequence table.

大多数商业安装创作工具和维克斯支持自定义序列,为自己的行为。

Most commercial setup authoring tools and WiX support custom sequences for your actions.

 
精彩推荐