App.config-自定义部分不起作用

Bri*_*n G 5 c#

我最近开始构建Web应用程序的控制台版本。我从web.config复制了自定义部分。到我的app.config。当我去获取配置信息时,出现此错误:

为x / y创建配置节处理程序时发生错误:无法从程序集“ System.Configuration”中加载类型“ x”

它不喜欢的行是:

返回ConfigurationManager.GetSection(“ X / Y”)为Z;

任何人都遇到这样的事情吗?

我能够添加

<add key="IsReadable" value="0"/> 
Run Code Online (Sandbox Code Playgroud)

在appSettings中阅读。

加成:

实际上,我确实对自定义部分进行了以下定义:

  <configSections>
    <sectionGroup name="x">
      <section name="y" type="zzzzz"/>
    </sectionGroup>

  </configSections>
Run Code Online (Sandbox Code Playgroud)

Ste*_*owe 4

听起来您的配置节处理程序未定义

<configSection>
    <section
            name="YOUR_CLASS_NAME_HERE"
            type="YOUR.NAMESPACE.CLASSNAME, YOUR.NAMESPACE, Version=1.1.0.0, Culture=neutral, PublicKeyToken=PUBLIC_TOKEN_ID_FROM_ASSEMBLY"
            allowLocation="true"
            allowDefinition="Everywhere"
          />
</configSection>
Run Code Online (Sandbox Code Playgroud)