简体   繁体   中英

WiX Installer Service File Locked Prompt

I have a WiX installer that installs a Windows service onto the system that relies on a database file. During the uninstall, a prompt always comes up saying that:

"Anothing application has exclusive access to the file '...\\db.mdf'. Please shut down all other applications, then click Retry."

The user is required to hit retry and then the uninstall works perfectly. However, this prompt will come up EVERY time you uninstall. I presume that the reason is that the ServiceControl has not completely terminated and has not released its resources (the .mdf file) yet once the uninstaller attempts the uninstall the service. I thought the "Wait" property should handle this.

<ServiceControl Id="ServiceControl_Start"
                Name="xxmyservicexx"
                Start="install"
                Remove="uninstall"
                Stop="both"
                Wait="yes" />

<!-- INSTALL AS SERVICE -->
<ServiceInstall Id="ServiceInstaller"
                                Type="ownProcess"
                                Vital="yes"
                                Name="xxmyservicexx"
                                DisplayName="xx my service xx"
                                Description="xxxxxxxx"
                                Start="auto"
                                ErrorControl="ignore"
                                Interactive="no" />

Everything does work correctly and it uninstalls correctly, but prompt does come up during every uninstall is not ideal. I realize I may be nitpicking a bit, but I'd like this to work correctly.

What can I do to avoid this prompt from coming up???

Assuming it's the service process that has exclusive access to that mdf file and that this is a timing issue, it may be something like this:

The service process no longer being a service does not mean that the containing process has terminated, only that it is no longer a service. The process then has to shutdown, and if closing that mdf file is "lazy" then the handles won't be free until the process is in the last stages of termination, and that may be some time later. If the code does explicitly close the mdf file, is the code to do that before the service says it's finished or after? I can imagine that the service might be very hasty in telling windows it's closed down (because you get other issues if it's not) but the rest of the housekeeping is later while the rest of the uninstall is still running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM