【发布时间】:2012-04-11 02:35:46
【问题描述】:
我正在尝试为 .net 4.0 项目设置 configSection。
<configuration>
<configSections>
<section name="MonitorFldrSection"
type="System.Configuration.NameValueFileSectionHandler, System, Version=4.0.0.0"
allowLocation="true"
allowDefinition="Everywhere"/>
</configSections>
<MonitorFldrSection>
<add name="fldr1" value="C:\Temp" />
<add name="fldr2" value="C:\Projects" />
</MonitorFldrSection>
<connectionStrings>
</connectionStrings>
<appSettings>
</appSettings>
</configuration>
但是,当我尝试添加密钥时,我得到的只是提示 注释或 CDATA 提示
当我尝试在代码中访问时
object obj = ConfigurationManager.GetSection("MonitorFldrSection");
我收到此错误:{“为 MonitorFldrSection 创建配置节处理程序时出错:无法加载文件或程序集“系统,版本 = 4.0.0.0”或其依赖项之一。系统找不到指定的文件。 (C:\Projects_4.0\NasImageIndexer\TestForm\bin\Debug\TestForm.exe.Config 第 5 行)"}
除了 NameValueFileSectionHandler,我还尝试了 AppSettingsSection 和 DictionarySectionHandler。
我做错了什么?
【问题讨论】:
标签: c#-4.0 app-config