Service WiX v3.7-安装程序卡在“上”;“启动服务”;

Service WiX v3.7-安装程序卡在“上”;“启动服务”;,service,wix,windows-installer,installation,wix3.7,Service,Wix,Windows Installer,Installation,Wix3.7,我正在用wix创建一个安装程序,它被挂在StartServices操作上。以下是我正在安装的唯一服务: <Component Id="CMP_RemindexNP.exe" Guid="{3FB99890-752D-4652-9412-72230695A520}"> <File Id="FILE_INSTALLFOLDER_RemindexNPEXE" Source="RemindexNP.exe&q

我正在用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>
如果我等5-10分钟,安装程序会告诉我“过早结束”。或者我可以在任务管理器中停止任务,几分钟后,我会得到相同的对话框

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


我的ServiceInstall元素有问题吗?

我的安装程序中有以下服务组件,它可以正常工作。当我在安装过程中遇到服务未正确启动的问题时,在服务中使用某种日志机制非常有帮助。由于某些配置错误,服务无法启动,安装无法完成。我无法分析并解决问题,因为我无法查看由安装程序创建并由该服务使用的事件日志。我建议您也这样做,因为从语法上看,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>

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


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

可能重复您之前的问题,我在那里为您提供了答案。在这个问题中,您省略了对srvany.exe的引用,这将使其他人无法了解您的问题。
<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>