假设我有以下配置文件
<?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(string name, ConfigurationSection section) 方法需要一个 configurationSection 对象,所以我不能使用它。