我的 App.config 文件标记为:
<configuration>
<configSections>
<section name="Custom" type="…" />
</configSections>
<Custom>
...
</Custom>
<Ignored>
...
</Ignored>
</configuration>
所以,我有一个配置文件,其中:
- 一个部分(“自定义”)由 API 处理,我已经为它编写了 ConfigurationSection 继承者
- 第二部分(“忽略”)我将自己解析,因为配置 API 不能让我解决我的任务。
当我运行程序时,出现异常“无法识别的配置部分‘忽略’”。
我是否可以告诉 ConfigurationManager 忽略这个“Ignored”部分?
最佳答案
您可以将以下内容添加到您的 <configSections>
元素:
<section name="Ignored" type="System.Configuration.IgnoreSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
关于c# - 告诉 ConfigurationManager 忽略 App.config 部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22714987/