首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法启动Windows服务,错误为1064

无法启动Windows服务,错误为1064
EN

Stack Overflow用户
提问于 2018-11-18 21:12:31
回答 7查看 96K关注 0票数 34

我编写了一个在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()

代码语言:javascript
复制
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()

代码语言:javascript
复制
protected override void OnStart(string[] args)
{
    this.ConfigureServices();

    this.timer.Start();
    this.logger.Information("SalesforceToJira service started.");
}

更新2

更多代码:

ConfigureServices()

代码语言:javascript
复制
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

EN

回答 7

Stack Overflow用户

回答已采纳

发布于 2019-07-19 08:41:17

由于@Siderite Zackwehdex的评论,我能够在EventViewer中找到底层异常的完整堆栈跟踪,具体如下:

Windows日志\应用程序

在我的例子中,我的服务名为"HttpDispatcher",它出现在顶部窗格中的"Source“列中。

我可以立即看到,这是由于依赖问题,我的.NET 4.7.2项目没有跨越我的.NET标准引用。(栗子)。

票数 42
EN

Stack Overflow用户

发布于 2019-11-05 10:31:56

我也面临着同样的问题。原因是我忘记在配置中正确设置数据库连接。

票数 3
EN

Stack Overflow用户

发布于 2019-05-15 18:46:54

我的服务启动时也有同样的错误1064。对我来说,我把服务注册为不是数据库中的有效用户。一旦加起来,效果很好。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53365517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档