gpt4 book ai didi

c# - App.config - 自定义部分不工作

转载 作者:太空狗 更新时间:2023-10-30 00:59:27 24 4
gpt4 key购买 nike

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

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

它不喜欢的行是:

将 ConfigurationManager.GetSection("X/Y") 作为 Z 返回;

有人遇到过这样的事情吗?

我能够添加

<add key="IsReadable" value="0"/> 

在 appSettings 中阅读它。

添加:

我确实定义了自定义部分:

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

</configSections>

最佳答案

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

<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>

关于c# - App.config - 自定义部分不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/306572/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com