简体   繁体   English

无法使用WiX安装程序启动服务

[英]Unable to start Service with WiX Installer

I'm trying to do a WiX installer with a service install for my C# project. 我正在尝试为我的C#项目安装带有服务安装的WiX安装程序。 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 : 我已经设置了ServiceInstall,但是当我运行安装程序时,此页面被阻止了:

在此处输入图片说明

After a few seconds I got the error : 几秒钟后,我得到了错误:

在此处输入图片说明

I created the WiX install from a Visual Studio Installer with the same parameters. 我使用相同的参数从Visual Studio安装程序创建了WiX安装。 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>

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. 尚未安装缺少的依赖项Dll(或依赖项的依赖项等)。 That includes the .NET framework. 其中包括.NET框架。

  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. 服务取决于安装到GAC的程序集,并且在启动服务时实际上不会提交这些程序集,因此这是缺少依赖项的特例。

  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. 您的OnStart代码崩溃可能导致此问题。 IMO Services should always have tracing available to trace the path and significant values to provide diagnostics. IMO服务应始终具有跟踪​​功能,以跟踪路径和有效值以提供诊断信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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