![](/img/trans.png)
[英]Wix + log4net: Windows service not logging after service is installed
[英]SQL Login issue from .Net 5 Windows service but not from console installed via Wix installer
我有一個連接到本地 SQL Express 數據庫實例的 .Net 5 Windows 服務 (WindowsBackgroundService)。 此數據庫實例和應用程序旨在在本地系統上運行,因此我嘗試對 SQL 進行 Windows 身份驗證,但未設置登錄。
該服務還使用 Wix 3.11 安裝程序安裝。 該服務安裝正常並完成(它也在我的服務和添加/刪除程序中列出)但該服務不會啟動。 在事件查看器日志中,它是這樣寫的:
用戶“NT AUTHORITY\SYSTEM”登錄失敗。 原因:無法打開明確指定的數據庫“MyDatabase”。 [客戶: ]
現在,我知道錯誤通常指向登錄問題,但令我感到困惑的是我正在使用我提到的 Windows 身份驗證,但更令人困惑的是,當我在安裝的文件夾中運行可執行文件時,它運行良好並連接到我的SQL 數據庫。
我猜這指向服務的權限,因為 Wix 安裝了它,這些權限不足以滿足 Windows 對 SQL 的授權?
所以,我想問題是,我如何配置 Wix 來安裝服務(希望不需要用戶在安裝過程中提供憑據)以便它可以使用 Windows Auth 訪問 SQL Express? 以下是該服務在安裝后的樣子:
這是 Wix.wxs 配置的相關部分:
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Name="MyService"
Vital="yes"
DisplayName="My Test Service"
Description="My Test Service"
Start="auto"
ErrorControl="normal"
Account="LocalSystem"
Interactive="no" >
<util:ServiceConfig
FirstFailureActionType="restart"
SecondFailureActionType="restart"
ThirdFailureActionType="restart"
ResetPeriodInDays="1"
RestartServiceDelayInSeconds="30" />
<util:PermissionEx
User="Everyone"
ServicePauseContinue="yes"
ServiceQueryStatus="yes"
ServiceStart="yes"
ServiceStop="yes"
ServiceUserDefinedControl="yes" />
</ServiceInstall>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="MyService" Wait="yes" />
謝謝!!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.