1

我正在使用 wix 创建一个安装程序,它正在挂起 StartServices 操作。这是我要安装的唯一服务:

<Component Id="CMP_RemindexNP.exe" Guid="{3FB99890-752D-4652-9412-72230695A520}">
    <File Id="FILE_INSTALLFOLDER_RemindexNPEXE" Source="RemindexNP.exe" KeyPath="yes"/>
    <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\RemindexNP\Parameters">
      <RegistryValue Id="rg_remNP1" Action="write" Name="AppDirectory" Value="[INSTALLFOLDER]" Type="string"/>
      <RegistryValue Id="rg_remNP2" Action="write" Name="Application" Value="[INSTALLFOLDER]RemindexNP.exe" Type="string"/>
    </RegistryKey>
    <ServiceInstall DisplayName="RemindexNP" Id="srv_remNP" Name="RemindexNP" Start="auto" Type="shareProcess" ErrorControl="ignore"/>
    <ServiceControl Id="srvc_remNP" Name="RemindexNP" Remove="both" Start="install" Stop="uninstall" Wait="no"/>
</Component>

这是日志文件中的 StartService 操作:

Action 17:15:08: StartServices. Starting services
Action start 17:15:08: StartServices.
StartServices: Service: Starting services
Action ended 17:15:08: StartServices. Return value 1.

如果我等待 5 - 10 分钟,安装程序会“提前结束”。或者我可以在任务管理器中停止任务,几分钟后,我会得到相同的对话框。

我尝试将 ServiceInstall 中的 Type 属性设置为 shareProcess 和 ownProcess,这两个都不起作用。我也尝试将 Wait 设置为 no 和 yes。

我的 ServiceInstall 元素有问题吗?

4

1 回答 1

0

我的安装程序中有以下服务组件,它可以工作。当我在安装过程中遇到服务未正确启动的问题时,在服务中使用某种日志记录机制非常有帮助。由于某些配置错误,服务无法启动,因此无法完成安装。我无法分析并解决问题,因为我无法查看由我的安装程序创建并由该服务使用的事件日志。我建议你走同样的路,因为你的 ServiceInstall 和 ServiceControl 元素在语法上看起来是正确的。

<Component Id="CMP_SERVICE" Guid="YOURGUIDHERE">
<File Source="Files/Service.exe" Id="Service.exe" KeyPath="yes" Compressed="no" />
<ServiceInstall
  Id="SvcInstallService"
  Name="Service"
  DisplayName="Service"
  Type="ownProcess"
  Description="Service Desc"
  Start="auto"
  ErrorControl="normal">
  <util:ServiceConfig
    ServiceName="Service"
    FirstFailureActionType="restart"
    SecondFailureActionType="restart"
    ResetPeriodInDays="1"
    RestartServiceDelayInSeconds="5"
    ThirdFailureActionType="restart"/>
</ServiceInstall>
<ServiceControl
  Id="sc_Service"
  Name="Service"
  Start="install"
  Stop="both"
  Remove="uninstall"
  Wait="no" />
</Component>

要创建 Eventlogsource,请使用以下代码:

<PropertyRef Id="NETFRAMEWORK20"/>
<PropertyRef Id="NETFRAMEWORK40FULL"/>
<Component Id="CMP_ServiceEventLogNetfx2" Guid="YOURGUIDHERE">
    <util:EventSource Name="Service" EventMessageFile="{[NETFRAMEWORK20INSTALLROOTDIR]}EventLogMessages.dll" Log="YourLog" KeyPath="yes"/>
    <Condition>
        <![CDATA[(Installed OR NETFRAMEWORK20) AND VersionNT < 600]]>
    </Condition>
</Component>
<Component Id="CMP_ServiceEventLogNetfx4" Guid="YOURGUIDHERE">
    <util:EventSource Name="Service" EventMessageFile="{[NETFRAMEWORK20INSTALLROOTDIR]}EventLogMessages.dll" Log="YourLog" KeyPath="yes"/>
    <Condition>
        <![CDATA[(Installed OR NETFRAMEWORK40FULL) AND VersionNT >= 600]]>
    </Condition>
</Component>

当然,您必须在您的服务中使用该事件日志。为此目的使用System.Diagnostics.EventLog该类及其方法。WriteEntry

最后一步是在安装过程中打开事件查看器 (eventvwr.msc) 并查看您的服务日志。

于 2013-08-29T10:53:26.750 回答