The problem with stopping the Windows service from the Installer class. Fire events too late

I am using Visual Studio 2010 with .NET 4.0. I have a Windows service installed from a Visual Studio installation project. In the installation project, I have the RemovePreviousVersion property equal to True.

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.

Therefore, when updating the software, the service already exists and can work. If it is running, then during installation, the installer asks that the file is already in use, and makes it possible to try again, continue or exit the installation. At this point, I can stop the service manually and click "Try Again" and it will work. But I do not want the end user to have to do this.

I installed a mailbox throughout the installer class BeforeInstall, BeforeUninstall (installer events), Install, Uninstall, Commit, Rollback (overridden methods), so I see when they are called during installation.

When you start the installation, the prompt that is used in the file appears before any installer class code. As soon as I stop the service and try again, it will continue and a message box will appear in the installation classes. Thus, the installer class is definitely called too late in the process to actually do anything.

I don’t think this was the behavior in earlier versions of .NET?

Has anyone come across this problem or have any suggestions?

I could try the InstallShiled LE project that comes with Visual Studio 2010 if I need (not sure if this will give the same result), but would prefer, if possible, if anyone knows the solution with the Visual Studio installation project.

+3
source share
1

FilesInUse. InstallValidate Windows .

, ( ) InstallValidate. .

, InstallValidate Visual Studio. , MSI Orca InstallExecuteSequence.

WiX .

+6

All Articles