My project has 2 different config sections(one technical & one functional) and some connection Strings. I would like to have in a same configSource file, the technical config section & the connection strings & in an other one the functional section. I know how to do this in 3 separate files but not in 2. It would be logical to have technical configuration like server hostnames & connection string in the same file.
My configuration files should look like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="MyService.Functional" type="Logger.ConfigHandler, Logger"/>
<section name="MyService.Technical" type="Logger.ConfigHandler, Logger"/>
</configSections>
<MyService.Functional configSource="Config\MyService.Functional.Config"/>
<MyService.Technical configSource="Config\MyService.Technical.Config"/>
<connectionStrings configSource="Config\MyService.Technical.Config">
</connectionStrings>
</configuration>
<MyService.Technical.Config>
<MyResourceServer value="tcp://MyServer:9000"/>
</MyService.Technical.Config>
<connectionStrings>
<add name="MyEntities" [...] />
</connectionStrings>
However if I mix the section MyService.Technical & the connectionStrings in the same file, the ConfigurationManager can't load any section anymore.
Do you have any tip to do this ? Is it absolutely mandatory to have 3 separate files for this case ?
根据我的经验,似乎将文件的内容加载为Referring元素的内部XML,这意味着您需要为外部引用的每个节使用不同的文件。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.