Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The DeviceConfig property is not needed at the top level. What you <strong>do</strong> need to do is add a property for your <code>ConfigurationElementCollection</code> devices. I would also rename your <code>Devices</code> class something a little less ambiguous, say, <code>DeviceElementCollection</code>. Try this:</p> <pre><code>Public Class DeviceConfig Inherits ConfigurationSection &lt;ConfigurationProperty("Devices")&gt; _ Public ReadOnly Property Devices() As DeviceElementCollection Get Return CType(Me("Devices"), DeviceElementCollection) End Get End Property End Class </code></pre> <p>Then, in your definition for <code>DeviceElementCollection</code>, you may have problems if you don't add the following:</p> <pre><code>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 </code></pre> <p>I wrote up a pretty long answer to a similar question (sorry, in C#) <a href="https://stackoverflow.com/questions/1651325/custom-web-config-section-handler/1651677#1651677">here</a>.</p> <p><strong>Update - how to use in code</strong> </p> <pre><code>Dim deviceConfiguration as DeviceConfig = ConfigurationManager.GetSection("deviceconfigs") For Each device As Device in deviceConfiguration.Devices '...whatever you need to do Next </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload