开发者

Runtime appconfig value changes

开发者 https://www.devze.com 2023-03-19 08:46 出处:网络
I want to ask about reading the app config property value. I can change some of the app config property value during runtime and I could use that property value in my code. So, how to get that runtim

I want to ask about reading the app config property value.

I can change some of the app config property value during runtime and I could use that property value in my code. So, how to get that runtime changed app config property value in my code? Is there any options to get the runtime changed app config value i开发者_开发技巧n C#.NET?


After saving the changes to the app config, do like this

ConfigurationManager.RefreshSection(sectionName);

to get the updated values.

Have a look at this page.


You can use ConfigurationManager to modify the config files and then use the RefreshSection after saving the settings but how are you trying to access the new information in case you are using GetSection then its unlikely you would get the changes as its getting read from cache. You will have to use OpenExeConfiguration i think to read the new changes.

It is not a good practice to change the configurations at runtime you should choose to revisit your purpose once again

0

精彩评论

暂无评论...
验证码 换一张
取 消