Is there any things to take care of when running your process or executable as service.Things like silent logging.Critical error reporting scenarios? etc? How do you handle it ?
Definition of Windows Services Unlike regular software that is launched by the end user and only runs when the user is logged on, Windows Services can start without user intervention and may continue to run long after the user has logged off.
You should create a Windows Service to run code in the background, without user interaction. For example, a Windows Service will run even if no-one is logged on. Any server that accepts connections (such as a mail, web, or FTP server) should usually be a Windows Service.
To verify that this service is running as a Windows process, open Task Manager, select the Processes tab and select the Show processes from all users check box.
You can't. A Service doesn't run under any "real" user at all, so it can't start any processes which can in any way interact with the user - input or output - as there won't necessarily be any user logging in while the service is running.
For critical error reporting, you are constrained to using the standard Service settings (in the properties of the installed service), or doing something yourself. This could be as simple a log file that logs unexpected errors (by using AppDomain.UnhandledException to catch and log them), using the Windows event log to log similar info, or having another process watch the service for errors (ie. the service stopping) and alerting someone.
Microsoft has an article entitled "Introduction to Windows Service Applications" that is a good general introduction to making services in .Net.
Some other things about developing Windows services from my experience:
OnStart
method of the service kicks off a new thread to run the service and then returns.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With