Rich
Rich

Reputation: 3821

Why is this service "not responding to the start or control request in a timely fashion"?

Background: A client has given me a third-party developed Windows service which they would like me to get running for them. However when I start the service, it times out and I get the 1053 "service did not respond ... timely fashion" error.

I've reflected the assembly to get the code it is executing in its start method, but from a cursory glance it looks like it should return.

Actual question: Can someone explain why this service is causing the 1053 error?

(Checking the log file has confirmed that the timer has been initialised and fires more than once before the service is terminated.)

private void InitTimers()
{
    if (this._config.RunMode == RunModes.Continuous)
    {
        this.srvcTimer.Interval = Math.Max(this._config.Interval.TotalSeconds, 1.0) * 1000.0;
    }
    else
    {
        this.srvcTimer.Interval = 60000.0;
    }
    this.srvcTimer.AutoReset = true;
    this.srvcTimer.Enabled = true;
}

Upvotes: 2

Views: 3889

Answers (2)

ChrisF
ChrisF

Reputation: 137148

The service constructor must return in a "timely" fashion for the service to start successfully. This means that you can't start a potentially expensive operation in the constructor but must delegate it to another thread.

Typically you might find that connecting to a local database is fine when developing the service, but once you deploy it and have to connect across the internet you find that it fails.

Without seeing the exact code in the constructor I can't say for certain, but if you move that into a thread the service should start successfully. Obviously this means that you need to have some way of checking that the service has actually started properly and reporting the error to the main program from the thread.

Upvotes: 3

Tristanto Kurniawan
Tristanto Kurniawan

Reputation: 1

This is because you already define your service log and you change it in code.

I encountering this recently, and the solution is Delete the service log registry in:

HKLM/System/ControlSet001/services/eventlog/<your service name>

If you are not sure with this, please backup your registry first.

Upvotes: -1

Related Questions