如何包括.Net的配置文件 [英] How to include a config file for .Net
本文介绍了如何包括.Net的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法让主要的.net配置文件app.config / web.config包括另一个配置文件?我需要将内容保存在单独的文件中,但将它们链接在一起。
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>
推荐答案
是的,你可以在main中包含单独的文件。 config使用如下的configSource属性:
Yep, you can include separate files into the main .config using the configSource attribute like so:
<securityConfiguration configSource="SomeOtherConfigFile.config" />
您以这种方式包含的外部配置文件必须位于同一目录(或子文件夹)主要.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属性
这篇关于如何包括.Net的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文