app.config创建配置节无效

c_- 2015-01-30 12:45:37

<sectionGroup name="userSettings" type="System.Configuration.NameValueSectionHandler">
<section name="id" type="System.Configuration.NameValueSectionHandler"/>
<section name="pw" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>

<userSettings>
<add key="id" value="myname"/>
<add key="pw" value="123456"/>
</userSettings>


...全文
254 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wind_cloud2011 2015-01-30
  • 打赏
  • 举报
回复
<configuration> <configSections> <sectionGroup name="userSettings" type="System.Configuration.NameValueSectionHandler"> <section name="id" type="System.Configuration.NameValueSectionHandler"/> <section name="pw" type="System.Configuration.NameValueSectionHandler"/> </sectionGroup> </configSections> <appSettings> <add key="id" value="myname"/> <add key="pw" value="123456"/> </appSettings> </configuration>
异常异长 2015-01-30
  • 打赏
  • 举报
回复
<configuration>
    <configSections>
        <sectionGroup name="system.web" type="System.Web.Configuration.SystemWebSectionGroup, System.Web, Version=%ASSEMBLY_VERSION%, Culture=neutral, PublicKeyToken=%MICROSOFT_PUBLICKEY%">
            <section name="authentication" type="System.Web.Configuration.AuthenticationSection, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowDefinition="MachineToApplication" />
            <!-- Other system.web sections -->
        </sectionGroup>
        <!-- Other configuration sections -->
    </configSections>
异常异长 2015-01-30
  • 打赏
  • 举报
回复
<configuration>

   <configSections>
      <section name="sampleSection"
               type="System.Configuration.SingleTagSectionHandler" />
   </configSections>

   <sampleSection setting1="Value1" 
                  setting2="value two" 
                  setting3="third value" />

</configuration>
c_- 2015-01-30
  • 打赏
  • 举报
回复
引用 4 楼 dongxinxi 的回复:
去掉<sectionGroup>直接用
<section name="userSettings" type="System.Configuration.NameValueSectionHandler"></section>
或者
<sectionGroup name="命名空间.userSettings" type="System.Configuration.ConfigurationSectionGroup, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<section name="userSettings" type="System.Configuration.NameValueSectionHandler"></section>
</sectionGroup>


这样也不行啊

<configSections>
<sectionGroup name="Helper.userSettings" type="System.Configuration.ConfigurationSectionGroup, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<section name="userSettings" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>

<userSettings>
<add key="Demo" value="test3"/>
</userSettings>


c_- 2015-01-30
  • 打赏
  • 举报
回复
引用 2 楼 stubble 的回复:
目录层次不对吧
请问应该是怎么样的呢?
c_- 2015-01-30
  • 打赏
  • 举报
回复
引用 4 楼 dongxinxi 的回复:
去掉<sectionGroup>直接用
<section name="userSettings" type="System.Configuration.NameValueSectionHandler"></section>
或者
<sectionGroup name="命名空间.userSettings" type="System.Configuration.ConfigurationSectionGroup, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<section name="userSettings" type="System.Configuration.NameValueSectionHandler"></section>
</sectionGroup>




<configSections>
<section name="test1" type="System.Configuration.NameValueSectionHandler"/>
<section name="test2" type="System.Configuration.NameValueSectionHandler"/>
</configSections>

<test1>
<add key="Demo" value="test"/>
</test1>




这是为什么啊。。。
  • 打赏
  • 举报
回复
去掉<sectionGroup>直接用
<section name="userSettings" type="System.Configuration.NameValueSectionHandler"></section>
或者
<sectionGroup name="命名空间.userSettings" type="System.Configuration.ConfigurationSectionGroup, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <section name="userSettings" type="System.Configuration.NameValueSectionHandler"></section>
</sectionGroup>
  • 打赏
  • 举报
回复
<sectionGroup name="userSettings" type="System.Configuration.ConfigurationSectionGroup, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
异常异长 2015-01-30
  • 打赏
  • 举报
回复
目录层次不对吧
kenfinal 2015-01-30
  • 打赏
  • 举报
回复
报错的地方调用方式发出来看看。

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧