发生错误创建配置节处理程序 [英] An error occurred creating the configuration section handler
问题描述
我有定义自定义栏目一dot.NET 4.0 Web应用程序:
I have a dot.NET 4.0 web application with a custom section defined:
<configuration>
<configSections>
<section name="registrations" type="System.Configuration.IgnoreSectionHandler, System.Configuration, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="true" restartOnExternalChanges="true" allowLocation="true"/>
....
在web.config文件的末尾我有各自的部分:
at the end of the web.config file I have the respective section:
....
<registrations>
.....
</registrations>
</configuration>
我每次打电话 System.Configuration.ConfigurationManager.GetSection(登记 );
我得到了以下异常:
出错创建注册配置节处理程序:给定的程序集名称或基本代码无效。 (异常来自HRESULT:0x80131047)(C:\ ... \web.config 13号线)
An error occurred creating the configuration section handler for registrations: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) (C:\...\web.config line 13)
我也使用Unity但不知道如果这是在错误相关的任何方式。
I'm also using Unity but don't know if that's in any way related to the error.
你以前遇到这个错误?我该如何解决?我需要用别的东西来代替 IgnoreSectionHandler
?
Have you faced this error before? How can I fix it? Do I need to replace the IgnoreSectionHandler
with something else?
推荐答案
您缺少在App.Config中的部分类型属性的命名空间。逸岸你不需要在那里为完整集信息。只有名称空间是足够的。
You are missing the Namespace in the type attribute of your section in App.Config. Infact you dont need the full assembly info in there either. only the namespace is enough
更新1
yourcustomconfigclass config =(yourcustomconfigclass)System.Configuration.ConfigurationManager.GetSection(
"registrations");
在配置文件中只写
and in config file only write
<section name="registrations" type="System.Configuration.IgnoreSectionHandler" requirePermission="true" restartOnExternalChanges="true" allowLocation="true"/>
这篇关于发生错误创建配置节处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!