Error 1053: the service did not respond to the start or control request in a timely fashion

后端 未结 30 963
無奈伤痛
無奈伤痛 2020-11-29 18:47

I have recently inherited a couple of applications that run as windows services, and I am having problems providing a gui (accessible from a context menu in system tray) wit

相关标签:
30条回答
  • 2020-11-29 19:39

    If you are using Debug code as below in your service the problem may arise.

    #if(!DEBUG)
    ServiceBase[] ServicesToRun;
    ServicesToRun = new ServiceBase[]
    {
    new EmailService()
    };
    ServiceBase.Run(ServicesToRun);
    #else
    //direct call function what you need to run
    #endif
    

    To fix this, while you build your windows service remove #if condition because it didn't work as it is.

    Please use argument for debug mode instead as below.

    if (args != null && args.Length > 0)
    {
    _isDebug = args[0].ToLower().Contains("debug");
    }
    
    0 讨论(0)
  • 2020-11-29 19:39

    Release build did not work for me, however, I looked through my event viewer and Application log and saw that the Windows Service was throwing a security exception when it was trying to create an event log. I fixed this by adding the event source manually with administration access.

    I followed this guide from Microsoft:

    • open registry editor, run --> regedit
    • Locate the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application
    • Right-click the Application subkey, point to New, and then click Key.
    • Type event source name used in your windows service for the key name.
    • Close Registry Editor.
    0 讨论(0)
  • 2020-11-29 19:40

    I want to echo mdb's comments here. Don't go this path. Your service is not supposed to have a UI... "No user interaction" is like the definining feature of a service.

    If you need to configure your service, write another application that edits the same configuration that the service reads on startup. But make it a distinct tool -- when you want to start the service, you start the service. When you want to configure it, you run the configuration tool.

    Now, if you need realtime monitoring of the service, then that's a little trickier (and certainly something I've wished for with services). Now you're talking about having to use interprocess communications and other headaches.

    Worst of all, if you need user interaction, then you have a real disconnect here, because services don't interact with the user.

    In your shoes I would step back and ask why does this need to be a service? And why does it need user interaction?

    These two requirements are pretty incompatible, and that should raise alarms.

    0 讨论(0)
  • 2020-11-29 19:40

    Both Local System Account and Local Service would not work for me, i then set it to Network Service and this worked fine.

    0 讨论(0)
  • 2020-11-29 19:41

    Once try to run your exe file. I had the same problem, but when I ran it direct by double click on the exe file, I got a message about .Net framework version, because I was released the service project with a framework which it wasn't installed on target machine.

    0 讨论(0)
  • 2020-11-29 19:43

    I also faced similar problem and found that there was issue loading assembly. I was receiving this error immediately when trying to start the service.

    To quickly debug the issue, try to run service executable via command prompt using ProcDump http://technet.microsoft.com/en-us/sysinternals/dd996900. It shall provide sufficient hint about exact error.

    http://bytes.com/topic/net/answers/637227-1053-error-trying-start-my-net-windows-service helped me quite a bit.

    0 讨论(0)
提交回复
热议问题