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).
Using app.config to determine a common config file
-
07-10-2022 - |
Question
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?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow