web.config:
<configSections>
 <section name="mySection" type="System.Configuration.NameValueSectionHandler"/>
</configSections><mySection>
 <add key="key_one" value="1"/>
</mySection>代码:
NameValueCollection config = (NameValueCollection) ConfigurationSettings.GetConfig("mySection");错误:
Section Handler生成时发生了例外。
然后就在
<section name="mySection" type="System.Configuration.NameValueSectionHandler"/>上表示成红色。请问有没有遇到过这种情况的呢?如何处理呢?是不是开发环境有问题呢?

解决方案 »

  1.   

    把这个去掉
    <section name="mySection" type="System.Configuration.NameValueSectionHandler"/>
    </configSections>在ini里用,webconfig里面不用
      

  2.   

    To: lovefootball
    认真一点。你没有遇到过这种情况吗?
      

  3.   

    http://www.cnblogs.com/caca/archive/2004/09/23/46091.aspx
    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconcreatingnewsectionhandlers.htm
      

  4.   

    能够直接用<section name="mySection" type="System.Configuration.NameValueSectionHandler"/>
    配置吗?在MSDN上的例子是用直接配置NameValueSectionHandler的,而且还用例子代码取出数据,为什么到我这里就会出错呢?还在研究中。我看过有些是继承了NameValueSectionHandler类来做为处理的,一定要这样做吗?
      

  5.   

    <section name="mySection" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />