By default, .NET application's configuration file is named after "exe file name".config. I'm wondering whether it is possible to have one application's configuration specified dynamically.
For example, the built application is "foo.exe". At runtime, the config file is "foo.exe.config". Is it possible to have it accept command line arguments to use other config file. So, the application can use other configuration like below.
foo.exe /config:bar.config
bar.config is used as config file insteand of foo.exe.config.
Best Answer
All of the above work well if you need to replace only AppSettings section.
In case you have to run with different config files (all sections) you might want to consider launching application using a host, that creates app domain for your main application and sets different config file depending on parameters you passed in.
Here's the code that worked for me: