[英]C# Windows Service Hangfire Error : 1053(GlobalConfiguration connecting to database)
我已经使用HangFire用C#编写了Windows服务。 Service1看起来像:
public Service1()
{
InitializeComponent();
GlobalConfiguration.Configuration.UseSqlServerStorage(@"Data Source=DESKTOP-B90D804\SQLEXPRESS;Initial Catalog=Leavingstone_Geocell_Students;Integrated Security=True");
}
protected override void OnStart(string[] args)
{
File.Create(AppDomain.CurrentDomain.BaseDirectory + "OnStart5.txt");
_server = new BackgroundJobServer();
}
protected override void OnStop()
{
File.Create(AppDomain.CurrentDomain.BaseDirectory + "OnStop5.txt");
_server.Dispose();
}
但是,当我尝试安装时,我一直从Windows服务获取错误1053。 表示服务没有及时响应启动或控制请求。
但是,如果我取出“ GlobalConfiguration.Configuration.UseSqlServerStorage(@"Data Source=DESKTOP-B90D804\\SQLEXPRESS;Initial Catalog=Leavingstone_Geocell_Students;Integrated Security=True");
“,它将起作用。
另外,当我从Visual Studio将其运行到调试模式时,它也可以正常工作,而无需删除GlobalConfiguration部分。 Windows服务使用本地系统帐户。
我已向NT AUTHORITY \\ SYSTEM用户授予sql权限,问题已解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.