Windows service configuration / connection string management RRS feed

  • Question

  • I just joined a company which has a lot of database servers and runs a lot of windows services to process the data. Currently the management of connectionstrings is somewhat arbitrary, some are stored in database tables, some in configurations, etc. Things get kind of messy when going from dev to test to production.

    So i just wrote a new windows service and i used enterprise library DAB to build a connection strings section in the app config. What i would love to do is mimic a web environment where i could keep separate config files locally and on various servers so that as the service is installed/re-installed in different places, the code will just work (as far as connecting to the correct dbs). Also it would eliminate a lot of if-else statements that are currently being used to check for hard coded debug setting and initialize connection strings.

    Is there a "Microsoft" way to handle this situation? I'm new to windows development so if there's an obvious answer i apologize.

    Monday, March 23, 2009 4:41 PM


  • My preference is for a centralized "configuration" data store.  This could be a database, an xml file, BizTalk's SSO, etc.  In this store (for things that have different environments to be deployed too...) you can store environment as a parameter for each connection string.  When the application goes to retrieve it's connection string it would simply need to know what environment the application was currently running in.  Then you have a central place to control what is connected too and your application only needs to be aware of itself.
    Friday, March 27, 2009 10:22 PM