[英]Unable to start Service with WiX Installer
我正在嘗試為我的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>
“無法啟動”錯誤可能是特權問題,但是無論是否具有特權,該消息都只是默認消息。
這些情況通常是服務本身或依賴項:
尚未安裝缺少的依賴項Dll(或依賴項的依賴項等)。 其中包括.NET框架。
服務取決於安裝到GAC的程序集,並且在啟動服務時實際上不會提交這些程序集,因此這是缺少依賴項的特例。
基本上,“啟動失敗”是指服務中的啟動代碼未完成。 您的OnStart代碼崩潰可能導致此問題。 IMO服務應始終具有跟蹤功能,以跟蹤路徑和有效值以提供診斷信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.