问题
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:
A missing dependent Dll (or dependency of a dependency etc) has not been installed. That includes the .NET framework.
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.
"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