Windows could not start service on Win Server 2008 R2 SP1 (Error 1053)
Asked Answered
A

5

13

This issue seems to be widely discussed, but I have problems with finding the solution in my particular case.

My service is set up to be running under Local System account. On my first machine with Windows 7 SP1 (64-bit) installed, everything works as expected. But, just after I try to start the service on my second machine with Windows Server 2008 R2 SP1 (64-bit), not even a second passes, and I'm facing this annoying error:

Windows could not start the ProService service on Local Computer
Error 1053: The service did not respond to the start or control request in a timely fashion

The System Log shows 2 entries:

The ProService service failed to start due to the following error: 
The service did not respond to the start or control request in a timely fashion.

and:

A timeout was reached (30000 milliseconds) while waiting for the ProService service to connect.

The implementation looks following:

Program.cs:

static void Main()
{
    AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
    ServiceBase.Run(new ServiceBase[] { new ProService() });
}

static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
    if (e != null && e.ExceptionObject != null)
    {
        Logger.Record(e.ExceptionObject);
    }            
}

ProService.cs:

public ProService()
{
    InitializeComponent();
}

protected override void OnStart(string[] args)
{
    try
    {
        RequestAdditionalTime(10000);
        FireStarter.Instance.Execute();
    }
    catch (Exception e)
    {
        Logger.Record(e);
        throw;
    }            
}

The OnStart method is just starting a new thread, so it takes almost NO time load to execute. I used RequestAdditionalTime statement just in case - to reject this matter as a source of my problem. In addition, as you can see, I'm handling all of the exceptions, but no exception is written to my custom service event log during the startup (btw: logging is working on the first win7 machine). How to investigate what's going on ?

Auld answered 2/1, 2013 at 11:16 Comment(4)
What happens in FireStarter.Instance.Execute()? Can you post some code for that method?Fagin
Then again, if it takes under a second for the error to happen then probably an assembly binding exception occurs. You can trace this by enabling FusionLog and by using the FusionLog Viewer: msdn.microsoft.com/en-us/library/e74a18c4(v=vs.100).aspx. Also, make sure the appropriate .NET framework is installed on the second machine.Fagin
The FireStarter.Instance.Execute() contains var thread = new Thread(x => WatchThread(new ThreadStart(ExecuteInternal))); thread.Start(); Framework is installed, the same on both machines. Unfortunately I've empty output in fuslogsw window (I accomplished all steps from this source: neovolve.com/post/2010/05/28/… and then attempt to start my service).Auld
Then the only helpful thing I can think of (and that I've used myself) is to use the Intellitrace standalone collector on that machine and collect trace detailed information about the execution path. See more here about the setup you need: msdn.microsoft.com/en-us/library/vstudio/hh398365.aspx. Once up and running you will be able to see exactly what is executed and hopefully pinpoint the issue.Fagin
A
10

I've figured out what was going on in a few steps:

  1. I've written console application - wrapper for what is basically done in OnStart method from service.
  2. I've executed console application - application started normally.
  3. I've copied content of service configuration file to console application configuration file.
  4. I've executed console application once again - application aborted silently and immediately (surprisingly similar to our service behavior, something is wrong).
  5. I've compared 2 configs - from service, and original from console application. As a result I've found some differences. Among others, there was such an entry - the source of the problem (after removal, everything works):

    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    

So basically I had out of date configuration file. Previously service was compiled under .NET 4.5, then I've changed the framework to 4.0 and deployed files to the server, but left the previous configuration file (I've changed the target framework because my development machine has .NET 4.5 while server does not). I wouldn't have thought the shown lines would hide all problems without any reasonable information, which could help to track the mess.

Auld answered 4/1, 2013 at 9:8 Comment(1)
Thanks a lot for answer. This saves a lot of time for me!Warehouseman
N
2

Check for missing dependencies/DLLs.

If you haven't already done so, allow your service to be invoked as a regular application (a great technique for long-term debugging) and see if it starts properly on your Windows 2008 machine.

If works that way, then there may be an issue with running in the LocalSystem account. Move on to starting your application from a command prompt running in the LocalSystem account (example setup here).

Nastassia answered 2/1, 2013 at 14:53 Comment(0)
H
1

I tried the following fix which was provided at this link

  1. Click Start, click Run, type regedit, and then click OK.

  2. Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control

  3. In the right pane, locate the ServicesPipeTimeout entry.
    Note If the ServicesPipeTimeout entry does not exist, you must create it. To do this, follow these steps:
    a. On the Edit menu, point to New, and then click DWORD Value.
    b. Type ServicesPipeTimeout, and then press ENTER.
  4. Right-click ServicesPipeTimeout, and then click Modify.
  5. Click Decimal, type 60000, and then click OK.
    This value represents the time in milliseconds before a service times out.
  6. Restart the computer.

But still I had the problem to start the service.

The fix which worked for me was,

  1. Go the services.msc
  2. Double click the service which you are trying to start.
  3. Take the Logon Tab
  4. Changed Log on as: to Local System account.
  5. Tried starting the service after this change.(Still gave the 1053 error)
  6. Took the Log on tab again, changed it to Network Service (gave a random new password)
  7. Tried starting the service again.(The service started perfectly)
Hekate answered 31/10, 2013 at 15:8 Comment(0)
H
0

I tried the below steps. It worked like a charm.

1.Go the services.msc 2.Double click the service which you are trying to start. 3.Take the Logon Tab 4.Changed Log on as: to Local System account. 5.Tried starting the service after this change.(Still gave the 1053 error) 6.Took the Log on tab again, changed it to Network Service (gave a random new password) 7.Tried starting the service again.(The service started perfectly)

But I just want to know what will be the issue.

Hatching answered 15/7, 2015 at 8:14 Comment(0)
B
0

After installing service, i have to gave full control permission(Everyone) for installation folder. Then, my service will started perfectaly.

Bountiful answered 3/8, 2015 at 13:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.