c#

您所在的位置:网站首页 windows启动异常 c#

c#

2023-08-22 09:30| 来源: 网络整理| 查看: 265

我写了一个在 Win10 上运行的 Windows 服务,在我决定稍微改变它之前,它运行得非常好。我重写了一些逻辑,在 Debug 和 Release 配置中测试了它,一切都很好。然后,我使用 installutil.exe/u %servicename.exe% 卸载了该服务的当前版本,并使用 installutil.exe %servicename.exe% 重新安装了该服务。 由于某种原因,这个新版本无法启动,并且崩溃并出现错误 1064。这是完整的错误文本:

Windows 无法在本地计算机上启动 %servicename% 服务。错误1064:服务在处理控制请求时出现异常。

我上次安装此服务时遇到了一些困难,但通过更改 Log On 属性很快解决了这些问题。这一次,它不起作用。请帮助解决这个问题。

谢谢。

更新 1

这是我的 Main() 和 OnStart() 服务方法:

主要()

static void Main() { #if DEBUG var service = new SalesforceToJiraService(); service.OnDebug(); Thread.Sleep(Timeout.Infinite); #else ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new SalesforceToJiraService() }; ServiceBase.Run(ServicesToRun); #endif }

OnStart()

protected override void OnStart(string[] args) { this.ConfigureServices(); this.timer.Start(); this.logger.Information("SalesforceToJira service started."); }

更新 2

更多代码:

ConfigureServices()

protected void ConfigureServices() { this.configuration = ConfigurationHelper.LoadConfiguration(ConfigurationPath); this.logger = ConfigurationHelper.ConfigureLogger(this.configuration.Logs.LogsPath); this.timer = ConfigurationHelper.ConfigureTimer(this.configuration.ProcessInterval.TotalMilliseconds, (sender, eventArgs) => this.ProcessCasesAsync(sender, eventArgs).GetAwaiter().GetResult()); this.salesforceClient = new SalesforceCliClient(this.configuration.Salesforce.CliPath); this.jiraClient = Jira.CreateRestClient( this.configuration.Jira.Url, this.configuration.Jira.Username, this.configuration.Jira.Password); }

我正在使用 Newtonsoft.JSON 反序列化 JSON 配置文件,使用 Serilog 进行日志记录,使用 System.Timers.Timer 进行周期性事件、用于 Jira API 的 AtlassianSDK 和用于 Salesforce 的 Salesforce CLI 的一些包装器。

最佳答案

感谢@Siderite Zackwehdex 的评论,我能够在 EventViewer 中找到底层异常的完整堆栈跟踪,位于:

Windows Logs\Application

在我的例子中,我的服务名为“HttpDispatcher”,它出现在顶部 Pane 的“源”列中。

我可以立即看出这是由于依赖性问题导致的,我的 .NET 4.7.2 项目没有拉动我的 .NET 标准引用。 (That ol' chestnut)。

关于c# - 无法启动 Windows 服务,错误 1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53365517/



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3