views:

628

answers:

1

I'm hoping there's a way to avoid custom configuration files if an application runs in a single AppDomain.

+1  A: 

As default the app config file of the default appdomain is in the process exe’s directory and named the same as the process exe + ".config". Also, note that a web.config file is an app.config - ASP.NET sets that as the config file for your appdomain.

To change the config file, set an AppDomainSetup.ConfigurationFile to the new location and pass that AppDomainSetup to your call to AppDomain.CreateDomain(). Then, run all of the code requiring that application config from within that new appdomain.

Note, though, that you won’t be able to choose the CLR version by setting the ConfigurationFile – at that point, a CLR will already be running, and there can only be one per process.

Application configuration files are per appdomain. So, you can set a ‘dll config’ by using the method above, but that means that it will be used for the entire appdomain, and it only gets one.

Niki