如何在运行时使用NameValueSectionHandler类型的新部分更新配置文件?

时间:2013-11-11 12:02:44

标签: .net configuration web-config app-config

假设我有以下配置文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <configSections>
  <sectionGroup name="sampleGroup">
   <section name="sampleSection1" type="System.Configuration.NameValueSectionHandler"/>
  </configSections>
 </sectionGroup>

 <sampleGroup>
  <sampleSection1>
   <add key="key1" value="False" />
   <add key="key2" value="True" />
  </sampleSection1>
 </sampleGroup>

</configuration>

我需要在运行时插入相同类型的新部分(nameValueSectionHandler)。 System.Configuration.Sections.Add(字符串名称,ConfigurationSection部分)方法期待一个configurationSection对象,所以我不能使用它。

0 个答案:

没有答案