Windows service on Local Computer started and then stopped error

前端 未结 11 1043
日久生厌
日久生厌 2020-12-07 14:35

Usually, I get this error: (The \"service name\" service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other service

相关标签:
11条回答
  • 2020-12-07 15:14

    If the service starts and stops like that, it means your code is throwing an unhandled exception. This is pretty difficult to debug, but there are a few options.

    1. Consult the Windows Event Viewer. Normally you can get to this by going to the computer/server manager, then clicking Event Viewer -> Windows Logs -> Application. You can see what threw the exception here, which may help, but you don't get the stack trace.
    2. Extract your program logic into a library class project. Now create two different versions of the program: a console app (for debugging), and the windows service. (This is a bit of initial effort, but saves a lot of angst in the long run.)
    3. Add more try/catch blocks and logging to the app to get a better picture of what's going on.
    0 讨论(0)
  • 2020-12-07 15:14

    The account which is running the service might not have mapped the D:-drive (they are user-specific). Try sharing the directory, and use full UNC-path in your backupConfig.

    Your watcher of type FileSystemWatcher is a local variable, and is out of scope when the OnStart method is done. You probably need it as an instance or class variable.

    0 讨论(0)
  • 2020-12-07 15:14

    I came across the same issue. My service is uploading/receiving XMLS and write the errors to the Event Log.

    When I went to the Event Log, I tried to filter it. It prompt me that the Event Log was corrupted.

    I cleared the Event Log and all OK.

    0 讨论(0)
  • 2020-12-07 15:15

    Please check that you have registered all HTTP endpoints in the local mahcine's Access Control List (ACL)

    http://just2thepoint.blogspot.fr/2013/10/windows-service-on-local-computer.html

    0 讨论(0)
  • 2020-12-07 15:15

    Use Timer and tick event to copy your files.

    On start the service, start the time and specify the interval in the time.

    So the service is keep running and copy the files ontick.

    Hope it help.

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