Service starts but immediately stops on Windows server

I want to run a standalone web applications as a service in Windows Server 2012. I succesfully created the service as described here:
When a try to start the service, a message appears which tells me that the service started but then immediately stopped because the service is not using or is not depending on other services.
The web applications itself works fine when I start it by double clicking its icon in Windows Explorer. But the app needs to run all the time, even when nobody is logged in, so it must be a service.
Did you experience this problem and did you find a solution?

I haven’t had this problem, but I would suggest you look at the event. You are likely accessing a file or other data that is not available in the windows service space. If you are prepared to post your App.Open Event code here we can probably help.

thanks for your reply.
This is very strange. I deleted the web app out of frustration from the server and I was ready to give up for now. After reading your reply I re-uploaded it to the server to see if it’s a file accessing issue (btw.: the only file the app uses is a SQLite-database which is (re)created by the app itself in the apps open event - if the file is not available). So I tried to start the service and now it started and it is still running… I will never understand Windows! I spent hours trying to make this thing run and now it suddenly works and I do not even know why.

Another possibility is that the port the web server is listening on is already in use. Perhaps you were running a debug version of your app on the same port as the service?

Hello Wayne,
after some testing it seems that the misleading error message indeed appears when the app can not access a file or data. I my case it was the database, which was accessible but the app could not read it, because it was encrypted (I experimented with an encrypted and an unencrypted version of the database). I have error checking built in but the apps error message did not show up when I started the service - only the confusing error message from Windows. So this time I would say: PEBKAC :wink:
Everything is working fine now.