title: How do I add custom ConfigurationSection to Assembly?
body: <p>I've spent a few weeks trying to figure this out, this is a duplicate of a question I asked previously but did not get a response to, so I am refining the question here.</p>
  
  <p>I've created a custom class:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Collections;
  using System.Configuration;
  
  namespace mssql_gui
  {
      public class TestConfigSection : ConfigurationSection
      {
          [ConfigurationProperty("", IsRequired = true, IsDefaultCollection = true)]
          public TestConfigInstanceCollection Instances
          {
              get { return (TestConfigInstanceCollection)this[""]; }
              set { this[""] = value; }
          }
      }
  
      public class TestConfigInstanceCollection : ConfigurationElementCollection
      {
          protected override ConfigurationElement CreateNewElement()
          {
              return new TestConfigInstanceElement();
          }
          protected override object GetElementKey(ConfigurationElement element)
          {
              return ((TestConfigInstanceElement)element).Key;
          }
      }
  
      public class TestConfigInstanceElement : ConfigurationElement
      {
          [ConfigurationProperty("key", IsKey = true, IsRequired = true)]
          public string Key
          {
              get { return (string)base["key"]; }
              set { base["key"] = value; }
          }
          [ConfigurationProperty("value", IsRequired = true)]
          public string Value
          {
              get { return (string)base["value"]; }
              set { base["value"] = value; }
          }
      }
  }
  </code></pre>
  
  <p>I've implemented it:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="testSection" type="mssql_gui.TestConfigSection"/&gt;
    &lt;/configSections&gt;
      &lt;startup&gt; 
          &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/&gt;
      &lt;/startup&gt;
    &lt;appSettings&gt;
      &lt;add key="Data Source" value="localhost\SQLEXPRESS"/&gt;
      &lt;add key="Initial Catalog" value="(empty)"/&gt;
      &lt;add key="Integrated Security" value="SSPI"/&gt;
    &lt;/appSettings&gt;
    &lt;testSection&gt;
      &lt;add key ="testKey" value="tesValue"/&gt;
    &lt;/testSection&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>and I have tried to access it, I am getting: </p>
  
  <blockquote>
    <p>An error occurred creating the configuration section handler for testSection: Could not load type 'mssql_gui.TestConfigSection' from assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.</p>
  </blockquote>
  
  <p>I understand that in the type, I should be declare an assembly dll, but I'm confused about that...because in the <a href="https://msdn.microsoft.com/en-us/library/2tw134k3.aspx" rel="nofollow noreferrer">official instructions by MS</a>, it says to create a new class for the handler:</p>
  
  <blockquote>
    <ol>
    <li><p>Create a public class that inherits from the
    System.Configuration.ConfigurationSection class.</p></li>
    <li><p>Add code to define the section's attributes and elements.</p></li>
    </ol>
  </blockquote>
  
  <p>Adding the class (at least through the visual studio interface) creates a .cs file, not a .dll assembly file, so how to I add that custom class to an assembly file in order to reference it in the <code>&lt;configSections&gt;</code> part of app.config?</p>