title: C# custom configuration: "The entry '' has already been added."
body: <p>I made a small custom configuration setting and I keep getting the error "The entry '' has already been added." when I try to use my custom collection. My code looks like this.</p>
  
  <p>The issue comes from my  tag.</p>
  
  <p>I don't see what I am missing since I have the same thing implemented for  and this one works perfectly. </p>
  
  <p>My .NET version is 4.0 if that helps.</p>
  
  <p>The app config section in question:</p>
  
  <pre><code>&lt;WorkersCollectionSection&gt;
  &lt;WorkersList&gt;
    &lt;Worker name="Category" isEnabled="false"
          assemblyNamespace="xxxxxx.xxxxxxxxxxxxxxx.Models.Category"
          queueName="CategorQueue"
          saveToFolder="false"&gt;
      &lt;HandlesList&gt;
        &lt;Handle name="xxxxxxx" isEnabled="true"/&gt;
        &lt;Handle name="yyyyyyy" isEnabled="true"/&gt;
        &lt;Handle name="zzzzzzzzzz" isEnabled="true"/&gt;
      &lt;/HandlesList&gt;
    &lt;/Worker&gt;
   &lt;WorkersList&gt;
  &lt;WorkersCollectionSection&gt;
  </code></pre>
  
  <p>The definition of the  property:</p>
  
  <pre><code>    [ConfigurationProperty("HandlesList")]
      [ConfigurationCollection(typeof(WorkerCollection), AddItemName = "Handle")]
      public HandleCollection HandleCollection
      {
          get { return (HandleCollection) base["HandlesList"]; }
      }
  </code></pre>
  
  <p>The code for the  tag :` public class HandleCollection : ConfigurationElementCollection, IEnumerable
      {</p>
  
  <pre><code>    public HandleCollection()
      {
          HandleElement handle = (HandleElement)CreateNewElement();
          BaseAdd(handle);
      }
  
      public override ConfigurationElementCollectionType CollectionType
      {
          get { return ConfigurationElementCollectionType.AddRemoveClearMap; }
      }
  
      protected override ConfigurationElement CreateNewElement()
      {
          return new HandleElement();
      }
  
      protected override object GetElementKey(ConfigurationElement element)
      {
          return ((HandleElement)element).Name;
      }
  
      public HandleElement this[int index]
      {
          get { return (HandleElement)BaseGet(index); }
          set
          {
              if (BaseGet(index) != null)
              {
                  BaseRemoveAt(index);
              }
              BaseAdd(index, value);
          }
      }
  
      public new HandleElement this[string Name]
      {
          get { return (HandleElement)BaseGet(Name); }
      }
  
      public int IndexOf(HandleElement handle)
      {
          return BaseIndexOf(handle);
      }
  
      public void Add(HandleElement url)
      {
          BaseAdd(url);
      }
  
      protected override void BaseAdd(ConfigurationElement element)
      {
          BaseAdd(element, false);
      }
  
      public void Remove(HandleElement handle)
      {
          if (BaseIndexOf(handle) &gt;= 0)
              BaseRemove(handle);
      }
  
      public void RemoveAt(int index)
      {
          BaseRemoveAt(index);
      }
  
      public void Remove(string name)
      {
          BaseRemove(name);
      }
  
      public void Clear()
      {
          BaseClear();
      }
  
      IEnumerator&lt;ConfigurationElement&gt; IEnumerable&lt;ConfigurationElement&gt;.GetEnumerator()
      {
          return (from i in Enumerable.Range(0, this.Count)
                  select this[i])
              .GetEnumerator();
      }
  
      protected override string ElementName
      {
          get { return "Handle"; }
      }
  
      public static explicit operator HandleCollection(Dictionary&lt;string, string&gt; v)
      {
          throw new NotImplementedException();
      }
  
      public static explicit operator HandleCollection(ConfigurationSection v)
      {
          throw new NotImplementedException();
      }
  }`
  </code></pre>
  
  <p>Code for the handle elements inside the list:</p>
  
  <pre><code> public class HandleElement: ConfigurationElement
  {
      [ConfigurationProperty("name", IsRequired = true)]
      [StringValidator(InvalidCharacters = "~!@#$%^&amp;*()[]{}/;'\"|\\", MinLength = 0, MaxLength = 60)]
      public string Name
      {
          get { return base["name"] as string; }
          set { base["name"] = value; }
      }
  
      [ConfigurationProperty("isEnabled", IsRequired = true)]
      public bool IsEnabled
      {
          get { return (bool)base["isEnabled"]; }
          set { base["isEnabled"] = value; }
      }
  
  }
  </code></pre>