gleanings from a variety of sources (including stackOverlflow), however when I come to use it, I get the following error message
\"The Configuration property \'devicecon
The DeviceConfig property is not needed at the top level. What you do need to do is add a property for your ConfigurationElementCollection devices. I would also rename your Devices class something a little less ambiguous, say, DeviceElementCollection. Try this:
Public Class DeviceConfig
Inherits ConfigurationSection
<ConfigurationProperty("Devices")> _
Public ReadOnly Property Devices() As DeviceElementCollection
Get
Return CType(Me("Devices"), DeviceElementCollection)
End Get
End Property
End Class
Then, in your definition for DeviceElementCollection, you may have problems if you don't add the following:
Public Overrides ReadOnly Property CollectionType() As System.Configuration.ConfigurationElementCollectionType
Get
Return ConfigurationElementCollectionType.BasicMap
End Get
End Property
Protected Overrides ReadOnly Property ElementName() As String
Get
Return "Device"
End Get
End Property
I wrote up a pretty long answer to a similar question (sorry, in C#) here.
Update - how to use in code
Dim deviceConfiguration as DeviceConfig = ConfigurationManager.GetSection("deviceconfigs")
For Each device As Device in deviceConfiguration.Devices
'...whatever you need to do
Next