Issue
When the output type is set to "Windows application" or "Console application", the service can’t be started and gives error "1053: The service did not respond to the start or control request in a timely fashion.". Digging behind that, I have found that it is due to Windows 10 (+ new Windows server versions) not allowing integration with the the UI (zero session) without the "Interactive Services Detection" service running – and that is not allowed in Windows 10.
Trying to solve that, using output type "Class library" instead, results in build error "CS8805: Program using top-level statements must be an executable.". I have read som articles saying that this can be due to a double semi-colon somewhere, but I haven’t found anything like that in the source files.
So – how do I create a Worker service which is functional on Windows 10 and new Windows servers?
Solution
A service can be a console or GUI .exe, it does not matter. However, it MUST call the service API when it starts:
When the service control manager starts a service process, it waits for the process to call the
StartServiceCtrlDispatcher
function. The main thread of a service process should make this call as soon as possible after it starts up (within 30 seconds).
Read more about services and look at the examples on MSDN…
Interactive services have been deprecated since Vista but some compatibility still remained for a while. That time is over, you just have to write a service and a helper app that runs in the user session.
Answered By – Anders
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0