Click here to Skip to main content
13,862,320 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi All,

I’ve inherited some VB code that I need to expand. I have very little experience with VB I usually work with C#. So I need help!!

I’m trying to add a custom section to the App.config file. This section will content multiple elements for suppliers. As follows:

  <section name="supplierInfo" type="SupplierInfoConfigurationHandler" allowLocation="true" allowDefinition="Everywhere" />

  <Supplier supplierid="1" loadnumber="45" paddedloadnumber="000000000045" />
  <Supplier supplierid="2" loadnumber="95" paddedloadnumber="000000000095" />

I found and modified some code for the handler class as follows:

Imports System
Imports System.IO
Imports System.Configuration
Imports System.Collections
Imports System.Xml
Imports Microsoft.VisualBasic

'Namespace FileConverter
Public Class SupplierInfoConfigurationHandler
    Implements IConfigurationSectionHandler

    Public SupplierInfoConfigurationHandler()

    Public Function Create(ByVal parent As Object, ByVal configContext As Object, ByVal section As System.Xml.XmlNode) As Object Implements System.Configuration.IConfigurationSectionHandler.Create
        Dim items As New List(Of SupplierInfo)
        Dim processesNodes As System.Xml.XmlNodeList

        processesNodes = section.SelectNodes("Supplier")

        For Each processNode As System.Xml.XmlNode In processesNodes
            Dim item As New SupplierInfo

            item.SupplierID = processNode.Attributes.ItemOf("supplierid").InnerText
            item.LoadNumber = processNode.Attributes.ItemOf("loadnumber").InnerText
            item.PaddedLoadNumber = processNode.Attributes.ItemOf("paddedloadnumber").InnerText

        Return items
    End Function
End Class

Then in my code I have another class called SupplierInfo that I Dim as a List and I use it as follows:

SuppliersInfo = System.Configuration.ConfigurationManager.GetSection("supplierInfo")

That’s where it throws an error on me. I get this error message; “An error occurred creating the configuration section handler for supplierInfo: Could not load type 'SupplierInfoSection' from assembly 'System.Configuration, Version=, Culture=neutral, PublicKeyToken=…'.”

How do I get this to load properly?

Your help as always will be greatly appreciated. Thanks


1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hate to answer my own question but this seams to resolve the error I'm getting. It's looking for a fully qualified name

<section name="supplierInfo" type="ASSEMBLYNAME.NAMESPACE.SupplierInfoConfigurationHandler, ASSEMBLYNAME.NAMESPACE" allowlocation="true" allowdefinition="Everywhere" />

I still have issues to work out. Thanks everyone for looking.
Nelek 19-Apr-12 18:27pm
You should not hate answering your own question, first of all it implies that you are really working on your code (what make other users more receptive to answer you in future questions). Second, you might have found a solution, but maybe other user read it and give you a better option, so you can improve your code and still learn more.
I see nothing wrong with it, just the opposite :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190214.1 | Last Updated 19 Apr 2012
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100