假设我有以下配置文件
<?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对象,所以我不能使用它。