Windows Service的Wix安装程序出现问题

时间:2018-10-17 11:55:21

标签: vb.net wix windows-services

我目前正在尝试将Windows Service应用程序的WIX安装包遇到问题。安装失败,并出现以下错误:

enter image description here

记录在事件日志中的一个:

“ Tops Batch Processor服务由于以下错误而无法启动: 该服务没有及时响应启动或控制请求。”

OnStart方法包括:

Protected Overrides Sub OnStart(ByVal args() As String)

    Try

        'Initialisation routine
        _logger.SendLog("TOPS Batch Processor service startup", NLog.LogLevel.Info, _fileCheckTimer, _fileCheckInterval, Nothing)
        Startup()

    Catch ex As Exception
        'Log the entry
        _logger.SendLog("Failed to start TOPS Batch Processor service", NLog.LogLevel.Error, _fileCheckTimer, _fileCheckInterval, ex)
        TearDown()
    Finally
        GC.Collect()
    End Try

End Sub

Startup方法包含一个筏初始化代码,该代码包含一些线程.Timer对象控制服务的活动:

Public Sub Startup()

    Try

                    'Add event handler for catching setting changes
        AddHandler PIServerChange, AddressOf PIServerChanged
        AddHandler PIPointSourceChange, AddressOf PIPointSourceChanged

        _licensedTo = GetSetting("LicensedTo")
        _productName = GetSetting("ProductName")

        'Establish the root folder for application data, nlog fonfiguration and log output
        _rootFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) & _
                                "\" & _licensedTo & "\" & _productName
        _nlogConfigPath = _rootFolder & "\config\nlog.config"
        _logFolder = _rootFolder & "\Logs\"

        'Get the timer intervals from the app config file
        _tagRefreshInterval = GetInterval("TagRefreshInterval")
        _fileCheckInterval = GetInterval("FileCheckInterval")
        _settingsRefreshInterval = GetInterval("SettingsRefreshInterval")

        'Instaniate the timer to refresh the memory cache of pi points (tags)
        _tagRefreshTimer = New Threading.Timer(New Threading.TimerCallback(AddressOf TagRefresh), Nothing, Timeout.Infinite, Timeout.Infinite)
        'Instaniate the timer to check for new files to process
        _fileCheckTimer = New Threading.Timer(New Threading.TimerCallback(AddressOf FileCheck), Nothing, Timeout.Infinite, Timeout.Infinite)
        'Instaniate the timer to check for dynamic setting changes
        _settingsTimer = New Threading.Timer(New Threading.TimerCallback(AddressOf SettingsRefresh), Nothing, Timeout.Infinite, Timeout.Infinite)

        'Initialise logging architecture
        _logger = New Logger(_nlogConfigPath, _logFolder, My.Settings.AppFullName, My.Application.Info.Version.ToString, False)
        _logger.SendLog("Started Tops Batch Processor Service", NLog.LogLevel.Warn)

        'Ensure that the application data folder structure is in place
        SetFolders()

        'Initialise the remaining class variables
        _successFolder = GetSetting("Processed")
        _failedFolder = GetSetting("Failed")
        _piPointSource = GetSetting("PIPointSource")
        _piTagFilter = "pointsource = '" & _piPointSource & "'"
        _tagRefreshMode = GetSetting("TagRefreshMode")

        'Establish PI Server Connection
        _piServerSetting = GetSetting("PIServer")
        _piPointSource = GetSetting("PIPointSource")
        _piServer = _piSdkApp.Servers(_piServerSetting)
        _topsPi = New TopsPI(_piServerSetting)

        'Obtain the initial tag listing from the PI Server @@ temp disable to test file specific tag refresh
        RefreshTags()

        '@@ Temp code _tagRefresh flag should be initilaised to true for synchronous file specific tag search
        '_tagRefreshCompleted = True

        'Re-start the timers with periodic signalling as per the specified check interval
        _settingsTimer.Change(_settingsRefreshInterval, _settingsRefreshInterval)
        _tagRefreshTimer.Change(_tagRefreshInterval, _tagRefreshInterval)
        _fileCheckTimer.Change(_fileCheckInterval, _fileCheckInterval)

        _started = True
    Catch ex As Exception
        _logger.SendLog("TOPS Batch Processor startup failure.", NLog.LogLevel.Error, ex)
    Finally

    End Try
End Sub

我对以前编写的Windows服务使用了类似的技术,没有遇到任何问题。据我所知,OnStart方法甚至没有被触发,这意味着问题可能出在WIX安装程序上,而不是应用程序上。即使使用'Start =“ disabled”',我也得到完全相同的错误消息,这一事实进一步支持了这种印象。因此,我提供了product.wxs文件以供参考:

       

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Property Id="ARPSYSTEMCOMPONENT">0</Property>
<Feature Id="ProductFeature" Title="TOPS Batch Processor" Level="1">
  <!-- This next section deals with the install/de-install of App Program File elements -->
  <ComponentRef Id="cmpDirSPEN" />
  <ComponentRef Id="cmpDirTopsBatch" />
  <ComponentRef Id="cmpTopsBatchExe" />
  <ComponentRef Id="cmpTopsBatchPdb" />
  <ComponentRef Id="cmpCommonDll" />
  <ComponentRef Id="cmpCommonPdb" />
  <ComponentRef Id="cmpLoggingDll" />
  <ComponentRef Id="cmpLoggingPdb" />
  <ComponentRef Id="cmpTopsBatchConfig" />
  <ComponentRef Id="cmpNlogDll" />
  <ComponentRef Id="cmpNlogXml" />

  <!-- This next section deals with the install/de-install of App Data elements i.e. Logs, Templates, Config area etc...-->
  <ComponentRef Id="cmpDirSPENAppData" />
  <ComponentRef Id="cmpDirTopsBatchAppData" />
  <ComponentRef Id="cmpDirTopsBatchStaging" />
  <ComponentRef Id="cmpDirTopsBatchProcessed" />
  <ComponentRef Id="cmpDirTopsBatchLogs" />
  <ComponentRef Id="cmpDirTopsBatchFailed" />
  <ComponentRef Id="cmpDirTopsBatchConfigNLog" />      
  <ComponentRef Id="cmpFilTopsBatchConfigNLog" />
</Feature>
 </Product>
   <Fragment>
<!-- The following section deals with the deployment of the application data files including logs, templates and userguide elements-->
<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="CommonAppDataFolder" Name="CommonAppData" >
    <Directory Id="dirSPENAppData" Name="SP Energy Networks">
      <Directory Id="dirTopsBatchAppData" Name="Tops Batch Processor">
        <Component Id="cmpDirTopsBatchAppData" Guid="{AGUID}" KeyPath="yes">
          <CreateFolder Directory="dirTopsBatchAppData" />
          <RemoveFile Id="PurgeTopsBatchAppData" Name="*.*" On="uninstall" />
          <RemoveFolder Id="idDirTopsBatchAppData" On="uninstall" Directory="dirTopsBatchAppData" />
        </Component>
        <Directory Id="dirTopsBatchLogs" Name="Logs">
          <Component Id="cmpDirTopsBatchLogs" Guid="{AGUID}">
            <CreateFolder Directory="dirTopsBatchLogs" />
            <RemoveFile Id="PurgeTopsBatchLogs" Name="*.*" On="uninstall" />
            <RemoveFolder Id="idDirTopsBatchLogsRemove" On="uninstall" Directory="dirTopsBatchLogs" />
          </Component>
        </Directory>
        <Directory Id="dirTopsBatchStaging" Name="Staging">
          <Component Id="cmpDirTopsBatchStaging" Guid="{AGUID}">
            <CreateFolder Directory="dirTopsBatchStaging" />
            <RemoveFile Id="PurgeTopsBatchStaging" Name="*.*" On="uninstall" />
            <RemoveFolder Id="idDirTopsBatchStagingRemove" On="uninstall" Directory="dirTopsBatchStaging" />
          </Component>
        </Directory>
        <Directory Id="dirTopsBatchProcessed" Name="Processed">
          <Component Id="cmpDirTopsBatchProcessed" Guid="{AGUID}">
            <CreateFolder Directory="dirTopsBatchProcessed" />
            <RemoveFile Id="PurgeTopsBatchProcessed" Name="*.*" On="uninstall" />
            <RemoveFolder Id="idDirTopsBatchProcessedRemove" On="uninstall" Directory="dirTopsBatchProcessed" />
          </Component>
        </Directory>
        <Directory Id="dirTopsBatchFailed" Name="Failed">
          <Component Id="cmpDirTopsBatchFailed" Guid="{AGUID}">
            <CreateFolder Directory="dirTopsBatchFailed" />
            <RemoveFile Id="PurgeTopsBatchFailed" Name="*.*" On="uninstall" />
            <RemoveFolder Id="idDirTopsBatchFailedRemove" On="uninstall" Directory="dirTopsBatchFailed" />
          </Component>
        </Directory>
        <Directory Id="dirTopsBatchConfigNLog" Name="Config">
          <Component Id="cmpDirTopsBatchConfigNLog" Guid="{AGUID}">
            <CreateFolder Directory="dirTopsBatchConfigNLog">
              <util:PermissionEx User="Users" GenericAll="yes"/>
            </CreateFolder>
            <RemoveFile Id="PurgeTopsBatchConfigNLog" Name="*.*" On="uninstall" />
            <RemoveFolder Id="idDirTopsBatchConfigNLogRemove" On="uninstall" Directory="dirTopsBatchConfigNLog" />
          </Component>
          <Component Id="cmpFilTopsBatchConfigNLog" Guid="*">
            <File Id="filTopsBatchConfigNLog" KeyPath="yes" Source="$(var.SourceDir)\nlog.config" />
          </Component>
        </Directory>
      </Directory>
      <Component Id="cmpDirSPENAppData" Guid="{AGUID}" KeyPath="yes">
        <RemoveFile Id="PurgeSPENAppData" Name="*.*" On="uninstall" />
        <RemoveFolder Id="idDirSPENAppData" On="uninstall" Directory="dirSPENAppData" />
      </Component>
    </Directory>
  </Directory>

  <!-- The following section deals with the deployment of the program files-->
  <Directory Id="ProgramFilesFolder">
    <Directory Id="dirSPEN" Name="SP Energy Networks">
      <Component Id="cmpDirSPEN" Guid="{AGUID}" KeyPath="yes">
        <CreateFolder Directory="dirSPEN" />
        <RemoveFile Id="PurgeSPEN" Name="*.*" On="uninstall" />
        <RemoveFolder Id="idDirSPEN" On="uninstall" Directory="dirSPEN" />
      </Component>
      <Directory Id="dirTopsBatch" Name="Tops Batch Processor">
        <Component Id="cmpDirTopsBatch" Guid="{AGUID}" KeyPath="yes">
          <CreateFolder Directory="dirTopsBatch" />
          <RemoveFile Id="PurgeTopsBatch" Name="*.*" On="uninstall" />
          <RemoveFolder Id="idDirTopsBatch" On="uninstall" Directory="dirTopsBatch" />
        </Component>
        <Component Id="cmpTopsBatchExe" Guid="{AGUID}">
          <File Id="filTopsBatchExe" KeyPath="yes" Source="$(var.SourceDir)\TopsBatch.exe" />
          <ServiceInstall Id="cmpTopsBatchExe" Type="ownProcess" Name="TopsBatch" DisplayName="Tops Batch Processor"
                      Description="Transmission Operations batch processing utility" Start="disabled" Account="LocalSystem" ErrorControl="normal">
            <util:PermissionEx  User="Everyone" ServicePauseContinue="yes" ServiceQueryStatus="yes"
                    ServiceStart="yes" ServiceStop="yes" ServiceUserDefinedControl="yes" />
          </ServiceInstall>
          <ServiceControl Id="cmpTopsBatchExe" Start="install" Stop="both" Remove="uninstall" Name="TopsBatch" Wait="no" />
        </Component>
        <Component Id="cmpTopsBatchPdb" Guid="*">
          <File Id="filTopsBatchPdb" KeyPath="yes" Source="$(var.SourceDir)\TopsBatch.pdb" />
        </Component>
        <Component Id="cmpCommonDll" Guid="*">
          <File Id="filCommonDll" KeyPath="yes" Source="$(var.SourceDir)\Common.dll" />
        </Component>
        <Component Id="cmpCommonPdb" Guid="*">
          <File Id="filCommonPdb" KeyPath="yes" Source="$(var.SourceDir)\Common.pdb" />
        </Component>
        <Component Id="cmpLoggingDll" Guid="*">
          <File Id="filLoggerDll" KeyPath="yes" Source="$(var.SourceDir)\Logging.dll" />
        </Component>
        <Component Id="cmpLoggingPdb" Guid="*">
          <File Id="filLoggerPdb" KeyPath="yes" Source="$(var.SourceDir)\Logging.pdb" />
        </Component>
        <Component Id="cmpTopsBatchConfig" Guid="*">
          <File Id="filTopsBatchConfig" KeyPath="yes" Source="$(var.SourceDir)\TopsBatch.exe.config" />
        </Component>
        <Component Id="cmpNlogDll" Guid="*">
          <File Id="filNlogDll" KeyPath="yes" Source="$(var.SourceDir)\NLog.dll" />
        </Component>
        <Component Id="cmpNlogXml" Guid="*">
          <File Id="filNlogXml" KeyPath="yes" Source="$(var.SourceDir)\NLog.xml" />
        </Component>
      </Directory>
    </Directory>
  </Directory>
</Directory>

如果我通过单击“忽略”按钮做出响应,并允许安装包完成并检查“程序文件”和CommonAppDataFolder区域下的安装元素,则似乎一切都已正确安装。

希望有人解决这个问题,因为这让我发疯了:-\

亲切问候 保罗·J。

0 个答案:

没有答案