Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After embracing the whole SOA thing, I've found that I'm gradually drowning in a sea of web.config and app.config files.

As an example, one system has 2 services that it interacts with. Each service has 3 config files - one for dev, one for staging and one for production. That's 6 config files. Then each application (3 different ones) that use these services needs three config files again, that's another 9. So that's 15 config files just for a relatively simple system.

How can I go about simplifying my configuration? Is there a better way of doing this? Should I try to make my config files environment agnostic? Should I investigate the whole WCF Discovery? Should I use the web.config transformation syntax?

share|improve this question
up vote 1 down vote accepted

You could put the config into code instead and set different values for the environments that depend on a registry key (or something) that is set globally on each environment's servers.

Migrating the settings from the config files to code is pretty easy (at leats I started writing WCF services using all-code configuration until the architects decided that 15 config files were the way to go... I guess it was easy for them to decide that as they didn't have to manage them)

share|improve this answer
That sounds pretty good gbjbaanb - if I don't need to change the config then I guess I don't need a config file! Any links on how to specify wcf binding settings programmatically? – LachlanB Jun 20 '13 at 23:41
@LachlanB I started with the MSDN reference and worked my way in adding the necessary bindings and contexts and security as the project progressed. You could read the tutorial that shows how to set things up in code for examples. – gbjbaanb Jun 21 '13 at 10:50

I used web.config transformation feature. [More information here.][1]

You may also modify your settings programatically per environment after reading the settings from the config file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.