运行时 appconfig 值更改
我想询问有关读取应用程序配置属性值的问题。
我可以在运行时更改一些应用程序配置属性值,并且可以在代码中使用该属性值。那么,如何在我的代码中获取运行时更改的应用程序配置属性值?在 C#.NET 中是否有任何选项可以获取运行时更改的应用程序配置值?
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 in C#.NET?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
保存对应用程序配置的更改后,执行以下操作
以获取更新的值。
请查看此页面。
After saving the changes to the app config, do like this
to get the updated values.
Have a look at this page.
您可以使用
ConfigurationManager
修改配置文件,然后在保存设置后使用RefreshSection
但如果您使用,您如何尝试访问新信息GetSection
那么当它从缓存中读取时,您不太可能获得更改。我认为您必须使用 OpenExeConfiguration 来阅读新的更改。在运行时更改配置不是一个好习惯,您应该选择再次重新审视您的目的
You can use
ConfigurationManager
to modify the config files and then use theRefreshSection
after saving the settings but how are you trying to access the new information in case you are usingGetSection
then its unlikely you would get the changes as its getting read from cache. You will have to useOpenExeConfiguration
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