I've created a custom app.config section
          <sectionGroup name="MySectionGroup">
            <section name="MySectionName" type="ConfigSections.MyConfigHandler, ConfigSections"/>

      <mytag name="MyName" customfield="customdata"/>

and a custom handler (most of the code from ms how-tos)

Imports System
Imports System.Collections
Imports System.Text
Imports System.Configuration
Imports System.Xml

Namespace ConfigSections
    Public Class MyConfigHandler
        Implements IConfigurationSectionHandler
        Public Function Create(ByVal parent As Object, ByVal configContext As Object, ByVal section As Xml.XmlNode) As Object Implements IConfigurationSectionHandler.Create

            ' Creates the configuration object that this method will return.
            ' This can be a custom configuration class.
            ' In this example, we use a System.Collections.Hashtable.
            Dim myConfigObject As New Hashtable

            ' Gets any attributes for this section element.
            Dim myAttribs As New Hashtable
            For Each attrib As XmlAttribute In section.Attributes
                If XmlNodeType.Attribute = attrib.NodeType Then
                    myAttribs.Add(attrib.Name, attrib.Value)
                End If

            ' Puts the section name and attributes as the first config object item.
            myConfigObject.Add(section.Name, myAttribs)

            ' Gets the child element names and attributes.
            For Each child As XmlNode In section.ChildNodes
                If XmlNodeType.Element = child.NodeType Then
                    Dim myChildAttribs As New Hashtable

                    For Each childAttrib As XmlAttribute In child.Attributes
                        If XmlNodeType.Attribute = childAttrib.NodeType Then
                            myChildAttribs.Add(childAttrib.Name, childAttrib.Value)
                        End If
                    myConfigObject.Add(child.Name, myChildAttribs)
                End If

            Return (myConfigObject)

        End Function
    End Class
End Namespace

But when I go to call read the data with
 Dim config As New Hashtable
        config = CType(System.Configuration.ConfigurationSettings.GetConfig("MySectionGroup/MySectionName"), Hashtable)

I get an ConfigurationException that it couldn't create ConfigSections.MyConfigHandler

What am I missing

Re: Windows Forms General Custom App.config sections and handler



I am also having the same problem. I wrote my code in C# and it worked. Then as per my company standards, I am changing my code from C# to VB.NET. I haven't changed anything as far as the config file is concerned.

I get a ConfigurationException that it couldn't create my handler.


<section name="TypeSubTypeSection" type="MyNamespace.TypeSubTypeSectionHandler, MyNamespace" />


Did you resolve your problem

Thanks & Regards

Re: Windows Forms General Custom App.config sections and handler

Zhi-Xin Ye - MSFT

Hi,the above

This sample may help you much.