0

Making Wix install for my service app I ran into such trouble - when I choose "repair" option, after install i am prompted to restart my pc. Actually my test install contains only two files.Although there are attributes that make installer stop the service (and it actually stops and uninstall service due to log), files are still busy with the service's process. What am I doing wrong? Is there any workarounds? How Can i get rid of restart prompting in this case? here is the code of installer:

<Fragment>
        <ComponentGroup Id="ProductComponents" Directory="AGENTFOLD">
            <Component Id="WindowsAgent" Guid="*">
        <File Id="WinAgent" KeyPath="yes" Source="WindowsAgent.exe"/>
        <ServiceInstall Id='WindowsAgentInst' Name='WindowsAgent' DisplayName='WindowsAgent' Type='ownProcess' Account='LocalSystem' Start='auto' ErrorControl='normal'/>
        <ServiceControl Id="WindowsAgentControl" Name="WindowsAgent" Stop="both" Start="install" Remove="uninstall" Wait="yes" />
      </Component>
      <Component Id="cmp2" Guid="GUIDHERE">
        <File Id="fil2" KeyPath="yes" Source="mydll.dll" />
      </Component>
        </ComponentGroup>
    </Fragment>

here is what log says:

Info 1603. The file C:\Program Files(x86)\WindowsAgent\mydll.dll is being held in use. Close that application and retry.

MSI (s) (88:78) [17:01:50:993]: Product: Setuptest. The file C:\Program Files (x86)\WindowsAgent\mydll.dll is being used by the following process: Name: WindowsAgent , Id 3384.

Info 1603. The file C:\Program Files (x86)\WindowsAgent\WindowsAgent.exe is being held in use. Close that application and retry.

MSI (s) (88:78) [17:01:51:182]: Product: Setuptest. The file C:\Program Files(x86)\WindowsAgent\WindowsAgent.exe is being used by the following process: Name: WindowsAgent , Id 3384.

Note that if I stop service manually before repair, everything works fine.

Nick B
  • 121
  • 1
  • 7

1 Answers1

1

Some of the common reasons for this are:

  1. The Service may be "stopped" in the sense that the service protocol has been completed and the process is no longer running as a service, but the process is still running and hasn't terminated. Serviced stopped != Process terminated. So it's timing thing, and if there is a lot going on it may take a while for the process to go away and release the Dlls. That doesn't happen when you shut down the service manually because nobody cares if the process takes a while to shut down. The install/uninstall is a race between the process shutting down and Windows wanting to get rid of the in-use Dlls. The service may be misbehaving in some way, can't rule that out.

  2. Something has a handle open to the service or the process. That seems unlikely in your case, but if there are apps on the system or in the install (like a custom action) that have opened service handles or process handles then they can't be fully terminated.

PhilDW
  • 19,260
  • 1
  • 14
  • 23
  • Thanks for reply.It is very helpful ! So i think i should add custom action after service stop to check the process state and to wait till it terminates. – Nick B Mar 30 '15 at 12:41
  • Maybe, or if you own the service code perhaps make an event log entry when the service stops being a service and as the very last thing the process does when it exits. That might indicate a timing race if you compare it with the MSI log, and inspecting the service code might be useful anyway to see what it does affter it stops being a service. A lot of cleanup code? – PhilDW Mar 30 '15 at 18:34