Reputation: 103
I am doing a windows service, using app.config, where there is a section to retrieve common configuration in another file. Using
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "filepath\\file");
works for me, but using
string appconfig = ConfigurationManager.AppSettings["CommonAppSetting"];
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", appconfig);
does not. It gets from the app.config of the windows service instead of the common configuration.
Anything I did wrong, or is there other better ways of doing it?
Upvotes: 0
Views: 110
Reputation: 1273
You need to reset some variables (ClientConfigPaths) in the ConfigurationManager
in order for it to refresh its values. These can be seen in the following accepted answer (complete with code for doing this legwork).
Change default app.config at runtime
Upvotes: 1