如何包含 .Net 的配置文件 [英] How to include a config file for .Net
问题描述
有没有办法让主 .net 配置文件 app.config/web.config 包含另一个配置文件?我需要将内容保存在单独的文件中,但将它们链接在一起.
这是我想要包含的示例:
<LocationSearch.Properties.Settings><setting name="MapQuestApiKey" serializeAs="String"><value>这里有一些值...</value></设置><setting name="MapQuestClientCode" serializeAs="String"><value>这里的另一个值...</value></设置></LocationSearch.Properties.Settings></applicationSettings></配置>
是的,您可以使用 configSource 属性将单独的文件包含到主 .config 中,如下所示:
以这种方式包含的外部配置文件必须位于主 .config 文件的同一目录(或子文件夹)中.
SectionInformation.ConfigSource 属性>
Is there a way to have the main .net configuration file app.config/web.config include another configuration file? I have a need to keep things in separate files, but link them together.
Here is a sample of what I want to include:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="LocationSearch.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<LocationSearch.Properties.Settings>
<setting name="MapQuestApiKey" serializeAs="String">
<value>some value here...</value>
</setting>
<setting name="MapQuestClientCode" serializeAs="String">
<value>another value here...</value>
</setting>
</LocationSearch.Properties.Settings>
</applicationSettings>
</configuration>
Yep, you can include separate files into the main .config using the configSource attribute like so:
<securityConfiguration configSource="SomeOtherConfigFile.config" />
External config files that you include this way must be within the same directory (or a subfolder) of the main .config file.
SectionInformation.ConfigSource Property
这篇关于如何包含 .Net 的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!