我编写了一个在Win10上运行的Windows,它运行得非常好,直到我决定稍微修改它。我重写了一些逻辑,在调试和发布配置中测试了它,一切都很好。然后,我使用installutil.exe /u %servicename.exe%卸载当前版本的服务,并使用installutil.exe %servicename.exe%重新安装它。由于某些原因,这个新版本无法启动,并且出现错误1064崩溃。这是完整的错误文本:
Windows could not start %servicename% service on Local Computer. Error 1064: An exception occurred in the service when handling the control request.
上一次安装此服务时,我遇到了一些困难,但很快就通过更改Log On属性来修复它们。这一次,它不起作用了。请帮我解决这个问题。
谢谢。
更新1
下面是我的Main()和OnStart()服务方法:
Main()
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用于周期性事件,AtlassianSDK用于Jira API,还有一些包装器用于Salesforce的Salesforce CLI。
发布于 2019-07-19 08:41:17
由于@Siderite Zackwehdex的评论,我能够在EventViewer中找到底层异常的完整堆栈跟踪,具体如下:
Windows日志\应用程序
在我的例子中,我的服务名为"HttpDispatcher",它出现在顶部窗格中的"Source“列中。
我可以立即看到,这是由于依赖问题,我的.NET 4.7.2项目没有跨越我的.NET标准引用。(栗子)。

发布于 2019-11-05 10:31:56
我也面临着同样的问题。原因是我忘记在配置中正确设置数据库连接。
发布于 2019-05-15 18:46:54
我的服务启动时也有同样的错误1064。对我来说,我把服务注册为不是数据库中的有效用户。一旦加起来,效果很好。
https://stackoverflow.com/questions/53365517
复制相似问题