Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not start Windows Service, Error 1064

I wrote a Windows Service to run on Win10, and it worked perfectly fine until I decided to change it a bit. I rewrote some logic, tested it in both Debug and Release configurations, and everything was fine. Then I uninstalled the current version of the service using installutil.exe /u %servicename.exe% and reinstalled it again using installutil.exe %servicename.exe%. For some reason, this new version cannot start, and it crashes with Error 1064. This is the full error text:

Windows could not start %servicename% service on Local Computer. Error 1064: An exception occurred in the service when handling the control request.

The last time I installed this service, I ran into some difficulties, but quickly fixed them by changing the Log On properties. This time, it is not working. Please help with this issue.

Thanks.

Update 1

Here are my Main() and OnStart() service methods:

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.");
}

Update 2

More code:

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);
}

I'm using Newtonsoft.JSON for deserializing a JSON configuration file, Serilog for logging, System.Timers.Timer for periodic events, AtlassianSDK for the Jira API and some wrappers over Salesforce CLI for Salesforce.

like image 410
semptra Avatar asked Nov 18 '18 21:11

semptra


5 Answers

Thanks to @Siderite Zackwehdex's comment, I was able to find the full stack trace of the underlying exception in EventViewer, under:

Windows Logs\Application

In my case, my service is named "HttpDispatcher", which appears in the "Source" column in the top pane.

I could see immediately it was due to a dependency issue where my .NET 4.7.2 project was not pulling across my .NET Standard references. (That ol' chestnut).

Event Viewer: Windows Logs/Application

like image 146
ne1410s Avatar answered Nov 20 '22 11:11

ne1410s


I faced the same issue. The reason was I forgot to set the Database connection properly in configurations.

like image 21
Sachith Wickramaarachchi Avatar answered Nov 20 '22 10:11

Sachith Wickramaarachchi


I had this exact same error 1064 starting my service. For me the user I had the service registered as was not a valid user in the database. Once added, it worked great.

like image 1
Elmer Avatar answered Nov 20 '22 10:11

Elmer


I also had the same error in my Windows Service. The reason was it can't read a configuration parameter, so it crash.

Adding some validation (bugfixing), the Windows Services can start it correctly.

like image 1
Francisco Avatar answered Nov 20 '22 09:11

Francisco


In my case the error was due to issues with Event log name

It got fixed after I went to RegEdit and deleted old service name from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

enter image description here

like image 1
asmgx Avatar answered Nov 20 '22 11:11

asmgx