After developing a Windows Service in C# today I have a few comments on the topic.
- If you are using an app that needs a config file, to write logs, or otherwise interact with the disk, make sure the thing has been told a specific path or that you have its files in the place it expects them, not where you expect them (C:\Windows\System32 seems to be a popular place)
- In general, a service should never interact with the UI, if you try it and the service resists, take direction from the service and leave things as they are, adding UI, or developing a UI control for a service is a bitch, it isn’t worth it.
- Make sure you have functional console/command line code before you convert the thing to a service, it makes things easier to just click Play in Visual Studio instead of having to install/uninstall a service and start/stop/start a service in Windows when changes occur
- Services can make life easier if you are open to the idea that easier sometimes means more complexity.
- Services cannot speak for themselves like a UI or command line application can, remember to read that event log (and write to it occasionally from the app)