如何从自定义位置读取app.config,即从.NET中的数据库读取 [英] How to read app.config from a custom location, i.e. from a database in .NET
问题描述
我试图覆盖我的自定义ServiceHost中的ApplyConfiguration方法从数据库读取配置,而不是app.config。理想情况下,我希望能够这样做:
配置config = GetConfigFromMyDatabase(...);
ServiceModelSectionGroup serviceModel = ServiceModelSectionGroup.GetSectionGroup(config);
有没有办法这样做而不写一个临时app.config文件?
使用:
System.Configuration .ConfigurationManager.OpenExeConfiguration(string exePath)
这样应该可以打开一个任意的app.config文件。 / p>
I am trying to override the ApplyConfiguration method in my custom ServiceHost to read the configuration from a database instead of app.config. Ideally I would want to be able to do something like this:
Configuration config = GetConfigFromMyDatabase(...);
ServiceModelSectionGroup serviceModel = ServiceModelSectionGroup.GetSectionGroup(config);
Is there any way to do this without writing a temp app.config file?
What about using:
System.Configuration.ConfigurationManager.OpenExeConfiguration(string exePath)
That should let you open an arbitrary app.config file.
这篇关于如何从自定义位置读取app.config,即从.NET中的数据库读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!