【发布时间】:2023-03-03 15:28:02
【问题描述】:
我使用 HangFire 在 C# 中创建了一个 Windows 服务,如下所示:
using System;
using System.Configuration;
using System.ServiceProcess;
using Hangfire;
using Hangfire.SqlServer;
namespace WindowsService1
{
public partial class Service1 : ServiceBase
{
private BackgroundJobServer _server;
public Service1()
{
InitializeComponent();
GlobalConfiguration.Configuration.UseSqlServerStorage("connection_string");
}
protected override void OnStart(string[] args)
{
_server = new BackgroundJobServer();
}
protected override void OnStop()
{
_server.Dispose();
}
}
}
我在 Windows 10 上使用 VS 2017。 编译后服务安装成功但未启动! 当我尝试手动启动时,它给出了著名的错误 1053:服务没有及时响应启动或控制请求。
我在 stackoverflow.com 中找到了有关授予 NT AUTHORITY\SYSTEM 权限的答案。它不能解决我的问题 请帮忙。谢谢。
【问题讨论】:
-
(如果“SQL 服务器”运行在同一台机器上,您是否告诉 SCM 您的服务依赖于它?)
标签: c# windows-services hangfire