![](/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.