title: Unit Testing C# Assembly with App.Config returns exception
body: <p>I have a 3 project solution that comprises of my DAL, an assembly, and my unit test project. I am using ReSharper.</p>
  
  <p>The following field, in my DAL, returns NULL for the object SectionHandler:</p>
  
  <pre><code>  public static DatabaseFactorySectionHandler SectionHandler =
          (DatabaseFactorySectionHandler) ConfigurationManager.GetSection("DatabaseFactoryConfiguration");
  </code></pre>
  
  <p>This is a line from a Factory class. Another class that inherits from it attempts to initialize the field from its constructor. </p>
  
  <p>I remembered I needed to add my App.config file to my Unit Test project (it was pointing to Machine.config). However, it hasn't fixed the problem. What I get instead when attempting to run my test is:</p>
  
  <blockquote>
  <pre><code>&gt;     failed: Configuration system failed to initialize System.Configuration.ConfigurationErrorsException: Configuration
  &gt; system failed to initialize ---&gt;
  &gt; System.Configuration.ConfigurationErrorsException: Unrecognized
  &gt; configuration section section.
  &gt; (C:\projects\MyAssembly.Tests\bin\Debug\MyAssembly.Tests.dll.temp.config
  &gt; line 3)
  </code></pre>
  </blockquote>
  
  <p>What I don't understand is the naming of the config file. In my directory I can see App.config has been renamed correctly (MyAssembly.Tests.dll.config), but there is no sign of temp.config.</p>
  
  <p>Here's my app.config (this is what is currently in my Test project, there are no other App.configs in the solution)</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="DatabaseFactoryConfiguration" type="MyClass.DatabaseFactorySectionHandler, MyClass.DBConnector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /&gt;
    &lt;/configSections&gt;
    &lt;connectionStrings&gt;
      &lt;clear/&gt;
      &lt;add name="Connector1" providerName="MyProvider" connectionString="myConnString" /&gt;
      &lt;add name="DB2Connector" providerName="IBM.Data.DB2" connectionString="myConnString2" /&gt;
    &lt;/connectionStrings&gt;
  
    &lt;DatabaseFactoryConfiguration Name="MyClassHere" ConnectionStringName="Connector1" /&gt;
    &lt;DatabaseFactoryConfiguration Name="MyOtherClassHere" ConnectionStringName="DB2Connector" /&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Why can't I get the unit test project to recognize my config file? Thanks.</p>