Vb.net 自定义配置节处理程序可以';找不到处理程序

Vb.net 自定义配置节处理程序可以';找不到处理程序,vb.net,configuration,configsection,Vb.net,Configuration,Configsection,我正在使用自定义处理程序AbraMain.MyConfigHandler在app.config中创建configSections 'Desc : Individual Application configuration Class 'Handle Tag : App.config -> <applicationList> -> <add> Public Class ApplInfoConfig Inherits ConfigurationElement &l

我正在使用自定义处理程序AbraMain.MyConfigHandler在app.config中创建configSections

'Desc : Individual Application configuration Class
'Handle Tag : App.config -> <applicationList> -> <add>
Public Class ApplInfoConfig
Inherits ConfigurationElement

<ConfigurationProperty("name", IsRequired:=True)> _
Public Property name() As String
  Get
    Return CStr(Me("name"))
  End Get
  Set(ByVal value As String)
    Me("name") = value
  End Set
End Property

<ConfigurationProperty("desc", DefaultValue:="", IsRequired:=False)> _
Public Property desc() As String
  Get
    Return CStr(Me("desc"))
  End Get
  Set(ByVal value As String)
    Me("desc") = value
  End Set
End Property

<ConfigurationProperty("subPath", DefaultValue:="", IsRequired:=False)> _
Public Property subPath() As String
  Get
    Return CStr(Me("subPath"))
  End Get
  Set(ByVal value As String)
    Me("subPath") = value
  End Set
End Property

<ConfigurationProperty("index", IsRequired:=True)> _
Public Property index() As Integer
  Get
    Return Me("index")
  End Get
  Set(ByVal value As Integer)
    Me("index") = value
  End Set
End Property

<ConfigurationProperty("iconIndex", DefaultValue:="0", IsRequired:=False)> _
Public Property iconIndex() As Integer
  Get
    Return Me("iconIndex")
  End Get
  Set(ByVal value As Integer)
    Me("iconIndex") = value
  End Set
End Property
End Class

'Desc : Collection of Individual Application configuration Class
'Handle Tag : App.config -> <applicationList>
Public Class ApplicationListCollection
Inherits ConfigurationElementCollection

Protected Overloads Overrides Function CreateNewElement() As System.Configuration.ConfigurationElement
  Return New ApplInfoConfig()
End Function

Protected Overrides Function GetElementKey(ByVal element As System.Configuration.ConfigurationElement) As Object
  Return CType(element, ApplInfoConfig).name()
End Function

End Class
End Namespace
错误:


无法从程序集“System.Configuration,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”加载类型“AbraMain.MyConfigHandler.ApplicationListCollection”。:“AbraMain.MyConfigHandler.ApplicationListCollection”

app.config

MyConfigHandler.vb 名称空间MyConfigHandler

'Desc : Individual Application configuration Class
'Handle Tag : App.config -> <applicationList> -> <add>
Public Class ApplInfoConfig
Inherits ConfigurationElement

<ConfigurationProperty("name", IsRequired:=True)> _
Public Property name() As String
  Get
    Return CStr(Me("name"))
  End Get
  Set(ByVal value As String)
    Me("name") = value
  End Set
End Property

<ConfigurationProperty("desc", DefaultValue:="", IsRequired:=False)> _
Public Property desc() As String
  Get
    Return CStr(Me("desc"))
  End Get
  Set(ByVal value As String)
    Me("desc") = value
  End Set
End Property

<ConfigurationProperty("subPath", DefaultValue:="", IsRequired:=False)> _
Public Property subPath() As String
  Get
    Return CStr(Me("subPath"))
  End Get
  Set(ByVal value As String)
    Me("subPath") = value
  End Set
End Property

<ConfigurationProperty("index", IsRequired:=True)> _
Public Property index() As Integer
  Get
    Return Me("index")
  End Get
  Set(ByVal value As Integer)
    Me("index") = value
  End Set
End Property

<ConfigurationProperty("iconIndex", DefaultValue:="0", IsRequired:=False)> _
Public Property iconIndex() As Integer
  Get
    Return Me("iconIndex")
  End Get
  Set(ByVal value As Integer)
    Me("iconIndex") = value
  End Set
End Property
End Class

'Desc : Collection of Individual Application configuration Class
'Handle Tag : App.config -> <applicationList>
Public Class ApplicationListCollection
Inherits ConfigurationElementCollection

Protected Overloads Overrides Function CreateNewElement() As System.Configuration.ConfigurationElement
  Return New ApplInfoConfig()
End Function

Protected Overrides Function GetElementKey(ByVal element As System.Configuration.ConfigurationElement) As Object
  Return CType(element, ApplInfoConfig).name()
End Function

End Class
End Namespace
'Desc:单个应用程序配置类
'句柄标记:App.config->->
公共类ApplInfoConfig
继承ConfigurationElement
_
作为字符串的公共属性名()
得到
返回CStr(名称)
结束
设置(ByVal值作为字符串)
Me(“名称”)=值
端集
端属性
_
公共属性desc()作为字符串
得到
返回CStr(Me(“描述”))
结束
设置(ByVal值作为字符串)
Me(“desc”)=价值
端集
端属性
_
作为字符串的公共属性子路径()
得到
返回CStr(Me(“子路径”))
结束
设置(ByVal值作为字符串)
Me(“子路径”)=值
端集
端属性
_
公共属性索引()为整数
得到
返回我(“索引”)
结束
设置(ByVal值为整数)
Me(“索引”)=值
端集
端属性
_
公共属性iconIndex()为整数
得到
返回我(“iconIndex”)
结束
设置(ByVal值为整数)
Me(“指数”)=价值
端集
端属性
末级
'Desc:单个应用程序配置类的集合
'句柄标记:App.config->
公共类ApplicationListCollection
继承ConfigurationElementCollection
受保护的重载将函数CreateNewElement()重写为System.Configuration.ConfigurationElement
返回新的ApplInfoConfig()
端函数
受保护的重写函数GetElementKey(ByVal元素作为System.Configuration.ConfigurationElement)作为对象
返回CType(元素,ApplInfoConfig).name()
端函数
末级
结束命名空间

问题似乎出在为自定义节指定处理程序的行中的
app.config

<section name="applicationList" type ="AbraMain.MyConfigHandler.ApplicationListCollection"/>
但是,您似乎还有第二个问题。对于配置部分,您需要有一个实现
配置部分
的处理程序

因此,您需要添加一个新类来执行此操作:

Public Class ApplicationList  
Inherits ConfigurationSection

' You need to do the implementation. There are plenty of
' examples available on-line.

End Class
然后指向你的
app.config
使用它:

<section name="applicationList" type ="AbraMain.MyConfigHandler.ApplicationList, AbraMain"/>


请使用编辑您的问题并格式化您的代码和错误消息,使其看起来像样。另外,请通过单击评论末尾显示的(x)删除您的评论,该评论只包含代码转储。最后,请阅读感谢您改进了您的问题。这使我能够阅读并提出解决方案。
<section name="applicationList" type ="AbraMain.MyConfigHandler.ApplicationList, AbraMain"/>