Windows service and dependencies
-
I have a windows service that I'm currently writing that will start automatically when the server that it is installed on is rebooted. The service will look up some data on a SQL table and then close the database and continue working without opening SQL again. This should work fine with one exception. What happens if the MSSQLSERVER service hasn't started yet? What is the procedure to add code to my service to create dependencies that MSSQLSERVER has to be running before my service starts? Any help is appreciated. :confused:
Lost in the vast sea of .NET
-
I have a windows service that I'm currently writing that will start automatically when the server that it is installed on is rebooted. The service will look up some data on a SQL table and then close the database and continue working without opening SQL again. This should work fine with one exception. What happens if the MSSQLSERVER service hasn't started yet? What is the procedure to add code to my service to create dependencies that MSSQLSERVER has to be running before my service starts? Any help is appreciated. :confused:
Lost in the vast sea of .NET
-
Insted of creating dependencies, can you just check the status of the MSSQLSERVER service and start it if it is not running?
I thought about that, but I don't want the service to just shut down if it can't find SQL. With dependencies doesn't the server sort of handle the order that it starts everything to make sure a service that depends on another service doesn't get started first? :confused:
Lost in the vast sea of .NET
-
I thought about that, but I don't want the service to just shut down if it can't find SQL. With dependencies doesn't the server sort of handle the order that it starts everything to make sure a service that depends on another service doesn't get started first? :confused:
Lost in the vast sea of .NET
-
I'd say you're right. I usually try to take the easy way out. :) Check this out: How to: Code Service Dependencies[^] It appears there is a
ServicesDependedOn
property on theServiceInstaller
class.It worked perfectly! Thanks! :)
Lost in the vast sea of .NET