App.config中 - 自定义栏目不工作 [英] App.config - custom section not working
问题描述
最近,我开始构建一个web应用程序的控制台版本。我复制从我的web.config我的自定义部分。我的app.config。当我去获取配置信息,我得到这个错误:
发生错误的X / Y创建配置节处理程序:未能从程序集加载类型'X'' System.Configuration
这是不喜欢该行是:
返回ConfigurationManager.GetSection(X / Y)为:Z;
任何人遇到这样的事情。
我是能够添加
<添加键=IsReadable值=0/>
在的appSettings和阅读。
增加:
我的确有这样的定义有关自定义部分:
< configSections>
< sectionGroup名称=X>
<节名称=Y型=ZZZZZ/>
< / sectionGroup>
< / configSections>
这听起来像你的配置节处理程序没有定义
< configSection>
<节
NAME =YOUR_CLASS_NAME_HERE
型=YOUR.NAMESPACE.CLASSNAME,YOUR.NAMESPACE,版本= 1.1.0.0,文化=中性公钥= PUBLIC_TOKEN_ID_FROM_ASSEMBLY
allowLocation =真正的
allowDefinition的=无处不在
/>
< / configSection>
I recently started building a console version of a web application. I copied my custom sections from my web.config. to my app.config. When I go to get config information i get this error:
An error occurred creating the configuration section handler for x/y: Could not load type 'x' from assembly 'System.Configuration
The line that it is not liking is:
return ConfigurationManager.GetSection("X/Y") as Z;
Anyone run into something like this?
I was able to add
<add key="IsReadable" value="0"/>
in the appSettings and read it.
Addition:
I do actually have this defined about the custom section:
<configSections>
<sectionGroup name="x">
<section name="y" type="zzzzz"/>
</sectionGroup>
</configSections>
it sounds like your config-section handler is not defined
<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>
这篇关于App.config中 - 自定义栏目不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!