2016-11-07 154 views
0

我正在嘗試使用針對我的C#項目的服務安裝來執行WiX安裝程序。這是我第一次嘗試,我不明白爲什麼它不起作用。無法使用WiX安裝程序啓動服務

我已經設置了ServiceInstall但是當我運行安裝程序,我擋在本頁面:

enter image description here

幾秒鐘後,我得到了錯誤:

enter image description here

我使用相同的參數從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> 

回答

3

的「啓動失敗」的錯誤可能是一個特權的問題,但該消息只是一個默認的消息是否是它的權限或沒有。

這些情況通常是服務本身或依賴性:

  1. 如果丟失一個依賴DLL(或依賴性等依賴性)尚未安裝。這包括.NET框架。

  2. 該服務依賴於正在安裝到GAC的程序集,並且這些程序集實際上並未在服務啓動時提交,因此這是缺少依賴關係的特例。

  3. 「無法啓動」基本上是服務中的啓動代碼沒有完成。您的OnStart代碼崩潰可能會導致此問題。國際海事組織服務部門應始終提供跟蹤以追蹤提供診斷的路徑和重要價值。

+0

幾個小時後,我終於找到了解決方案。確實缺少一個dll。我試圖運行相同的服務的另一個程序,我錯過了SQL服務器的DLL。我下載了DLL,現在它工作。 –

相關問題