title: C#/.NET 4.0 Creating custom configElements and configCollection
body: <p>Trying to create a custom configuration elements as seen below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="ScriptObjects" type="ScriptObjectSection" /&gt;
    &lt;/configSections&gt;
    &lt;ScriptObjects&gt;
      &lt;users&gt;
        &lt;user name="Justin"/&gt;
      &lt;/users&gt;
    &lt;/ScriptObjects&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>But I'm getting this error: </p>
  
  <blockquote>
    <p>An error occurred creating the configuration section handler for
    ScriptObjects: Could not load type 'ScriptObjectSection' from assembly
    'System.Configuration, Version=4.0.0.0, Culture=neutral</p>
  </blockquote>
  
  <p>I want to have the ability of looping through all user elements.</p>
  
  <p>I've searched the net and found a sample from MSDN, but its a slightly too cryptic for me to understand.</p>
  
  <p>Below is the code I have for the custom element, element collection, and config section.</p>
  
  <p>Does any one have any guidance on this? Where am I messing up?</p>
  
  <pre><code>public class ScriptObjectSection : ConfigurationSection
  {
      [ConfigurationProperty("Users")]
      [ConfigurationCollection(typeof(UserCollection))]
      public UserCollection Users
      {
          get { return (UserCollection)base[ "users" ]; }
      }
  }
  
  public class UserElement : ConfigurationElement
  {
      [ConfigurationProperty( "name" )]
      public string Name
      {
          get { return (string)this[ "name" ]; }
      }
  }
  
  public class UserCollection : ConfigurationElementCollection
  {
      public override ConfigurationElementCollectionType CollectionType
      {
          get
          {
              return ConfigurationElementCollectionType.AddRemoveClearMap;
          }
      }
  
      protected override ConfigurationElement CreateNewElement()
      {
          throw new NotImplementedException();
      }
  
      protected override object GetElementKey( ConfigurationElement element )
      {
          throw new NotImplementedException();
      }
  
      public UserElement this[ int index ]
      {
          get { return (UserElement)BaseGet( index ); }
      }
  }
  </code></pre>
  
  <p>The Error is thrown on this line:</p>
  
  <pre><code> ScriptObjectSection sos = ConfigurationManager.GetSection("ScriptObjects") as ScriptObjectSection;
  </code></pre>