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

后端 未结 30 843
無奈伤痛
無奈伤痛 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:32

    After fighting this message for days, a friend told me that you MUST use the Release build. When I InstallUtil the Debug build, it gives this message. The Release build Starts fine.

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

    Adding 127.0.0.1 crl.microsoft.com to the "Hosts" file solved our issue.

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

    Copy the release DLL or get the dll from release mode rather than Debug mode and paste it to installation folder,,it should work

    0 讨论(0)
  • 2020-11-29 19:36
    1. Build project in Release Mode.
    2. Copy all Release folder files to source path.
    3. Execute Window service using command prompt window in administrative access.
    4. Never delete files from source path.

    At lease this works for me.

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

    If you continue down the road of trying to make your service interact with the user's desktop directly, you'll lose: even under the best of circumstances (i.e. "before Vista"), this is extremely tricky.

    Windows internally manages several window stations, each with their own desktop. The window station assigned to services running under a given account is completely different from the window station of the logged-on interactive user. Cross-window station access has always been frowned upon, as it's a security risk, but whereas previous Windows versions allowed some exceptions, these have been mostly eliminated in Vista and later operating systems.

    The most likely reason your service is hanging on startup, is because it's trying to interact with a nonexistent desktop (or assumes Explorer is running inside the system user session, which also isn't the case), or waiting for input from an invisible desktop.

    The only reliable fix for these issues is to eliminate all UI code from your service, and move it to a separate executable that runs inside the interactive user session (the executable can be started using the global Startup group, for example).

    Communication between your UI code and your service can be implemented using any RPC mechanism: Named Pipes work particularly well for this purpose. If your communications needs are minimal, using application-defined Service Control Manager commands might also do the trick.

    It will take some effort to achieve this separation between UI and service code: however, it's the only way to make things work reliably, and will serve you well in the future.

    ADDENDUM, April 2010: Since this question remains pretty popular, here's a way to fix another common scenario that causes "service did not respond..." errors, involving .NET services that don't attempt any funny stuff like interacting with the desktop, but do use Authenticode signed assemblies: disable the verification of the Authenticode signature at load time in order to create Publisher evidence, by adding the following elements to your .exe.config file:

    <configuration>
        <runtime>
            <generatePublisherEvidence enabled="false"/>
        </runtime>
    </configuration>
    

    Publisher evidence is a little-used Code Access Security (CAS) feature: only in the unlikely event that your service actually relies on the PublisherMembershipCondition will disabling it cause issues. In all other cases, it will make the permanent or intermittent startup failures go away, by no longer requiring the runtime to do expensive certificate checks (including revocation list lookups).

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

    I had this problem and it drove me nuts for two days… If your problem similar to mine:

    I have settings “User settings” in my windows service, so the service can do self-maintenance, without stopping and starting the service. Well, the problem is with the “user settings”, where the config file for these settings is saved in a folder under the user-profile of the user who is running the windows service under the service-exe file version.

    This folder for some reason was corrupted. I deleted the folder and service start working back again happily as usual…

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