配置一个configSections,在读取时报异常,代码如下
 Dictionary<string, string> _dic = ConfigurationManager.GetSection("sampleSection") as Dictionary<string, string>;异常信息:创建 sampleSection 的配置节处理程序时出错: 未能从程序集“System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”中加载类型“ConfigSections.SingleTagSectionHandler”。 (E:\个人测试项目\ConfigSectionTest\ConfigSections\bin\Debug\ConfigSections.vshost.exe.Config line 5)
PS:已经引用:system.configuration.dll异常

解决方案 »

  1.   

    应该先读取配置文件,修改代码为:var config = ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);
    var s = (TestConfigurationSection) config
        .GetSection("sampleSection ");
      

  2.   

    你搞得是app.config吧,换成web.config 应该就可以了。
      

  3.   

    这个是MSDN上面的解释,实例也是webconfig,http://msdn.microsoft.com/zh-cn/library/2tw134k3(v=vs.100).aspx
    好了,记得给分哦。