【问题标题】:Unable to start Service with WiX Installer无法使用 WiX 安装程序启动服务
【发布时间】:2016-11-07 14:47:48
【问题描述】:

我正在尝试为我的 C# 项目做一个带有服务安装的 WiX 安装程序。这是我第一次尝试,我不明白为什么它不起作用。

我已经设置了 ServiceInstall,但是当我运行设置时,我在此页面中被阻止:

几秒钟后我得到了错误:

我从具有相同参数的 Visual Studio 安装程序创建了 WiX 安装。有代码:

<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>

【问题讨论】:

    标签: windows wix installation


    【解决方案1】:

    “启动失败”错误可能是权限问题,但无论是否是权限,该消息都只是默认消息。

    这些情况通常是服务本身或依赖:

    1. 尚未安装缺少的依赖 Dll(或依赖项的依赖项等)。这包括 .NET 框架。

    2. 服务依赖于安装到 GAC 的程序集,而这些程序集在服务启动时并未实际提交,因此这是缺少依赖项的一种特殊情况。

    3. “启动失败”基本上是服务中的启动代码没有完成。您的 OnStart 代码中的崩溃可能会导致此问题。 IMO 服务应始终具有可用于跟踪路径和重要值以提供诊断的跟踪。

    【讨论】:

    • 几个小时后,我终于找到了解决方案。确实缺少一个dll。我尝试使用相同的服务运行另一个程序,但我缺少 SQL 服务器的 dll。我下载了 dll,现在它可以工作了。
    • 我面临同样的问题。通过 InstallUtil 安装时,它运行良好。可能是什么错误?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多