Unable to start Service with WiX Installer

耗尽温柔 提交于 2019-12-25 14:11:43

问题


I'm trying to do a WiX installer with a service install for my C# project. It's the first time I try and I don't understand why it doesn't work.

I have set a ServiceInstall but when I run the setup, I'm blocked in this page :

After a few seconds I got the error :

I created the WiX install from a Visual Studio Installer with the same parameters. There is the code :

<Product ... />

<Feature Id="ProductFeature" Title="$(var.product)" Level="1">
    <ComponentRef Id ="MyService"/>
</Feature>

<UIRef Id="WixUI_InstallDir"/>

<!-- Set install directory -->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER"/>
</Product>

<Fragment>
    <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="$(var.product)">
            <Component Id="MyService" Guid="{GUID-HERE}" KeyPath="yes">        
              <!-- service will need to be installed under Local Service -->

              <ServiceInstall
                Id="MyService"
                Type="ownProcess"
                Vital="yes"
                Name="MyService"
                DisplayName="Service"
                Description=""
                Start="auto"
                Account="NT AUTHORITY\LocalService"
                ErrorControl="normal"/>
              <ServiceControl Id="StartDDService" Name="MyService" Start="install" Wait="no" />
              <ServiceControl Id="StopDDService" Name="MyService" Stop="both" Wait="yes" Remove="uninstall" />
            </Component>        
        </Directory>
    </Directory>
</Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents">
      <Component Id="ProductComponent" Guid="{}" Directory="INSTALLFOLDER">

        <File Id="MyService.exe" Source="$(var.MyService.TargetDir)\MyService.exe"/>
      </Component>
    </ComponentGroup>
  </Fragment>

回答1:


The "failure to start" error could be a privilege issue, but the message is just a default message whether it it's privilege or not.

These cases are usually the service itself or a dependency:

  1. A missing dependent Dll (or dependency of a dependency etc) has not been installed. That includes the .NET framework.

  2. The service depends on an assembly being installed to the GAC, and these assemblies are not actually committed when services are started, so that's a special case of a missing dependency.

  3. "Failure to start" is basically that the start code in the service didn't complete. A crash in your OnStart code could cause this. IMO Services should always have tracing available to trace the path and significant values to provide diagnostics.



来源:https://stackoverflow.com/questions/40467984/unable-to-start-service-with-wix-installer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!