I have an application that runs as a windows service. It stores various parameter settings in the database, which are viewed when the service starts. I built a service to support various types of databases (SQL Server, Oracle, MySQL, etc.). Often end users choose the software configuration to use SQL Server (they can simply change the configuration file with the connection string and restart the service). The problem is that when their machine boots up, often from the moment SQL Server starts after my service, so my service errors occur at startup because it cannot connect to the database. I know that I can specify dependencies for my service to help Windows Manager start the corresponding services in front of mine. However, I do not know which services should depend on the installation (when my service is registered), since the user can subsequently change the databases.
So my question is: is there a way for a user to manually specify service dependencies based on the database used? If not, what is the right design approach I should take? I thought about trying to do something like 30 minutes after starting my service before connecting to the database, but it looks different in different ways. I also thought about trying to "lazily" connect to the database; the problem is that I need a connection right after launch, since the database contains various pieces of vital information that I need when I first start. Any ideas?
c # database windows-services
Dennis
source share