title: Referenced assembly can not read app.config
body: <p>I'm having problems with my unit tests. The problem is: I'm using Sitecore. Another question I asked about this is: <a href="https://stackoverflow.com/questions/11503985/unit-testing-sitecore-licensemanager">Unit Testing Sitecore LicenseManager</a></p>
  
  <p>My problem is that I get the exception:</p>
  
  <pre><code>Test method foo.Bar.Framework.Tests.Core.UnitTest1.TestMethod1 threw exception: 
  System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.TypeInitializationException: The type initializer for 'Sitecore.Services.Heartbeat' threw an exception. ---&gt; System.InvalidOperationException: Could not read Sitecore configuration.
  </code></pre>
  
  <p>I looked into the code with dotPeek and the function Sitecorre.Configuration.Settings.GetSetting("HeartbeatInterval") throws an exception. Because it can not read the configuration.
  When I add the same code to my unit test .cs file and debug the test it can read the configuration.
  The setting is also available in the app.config</p>
  
  <p>It looks like the referenced assembly cannot read the config and the test itself can.
  How can I fix this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The Settings.GetSetting() function eventually uses Sitecore.Configuration.ConfigReader.GetConfigNode(). This Function eventually uses this function:</p>
  
  <pre><code>private static ConfigReader GetReader()
  {
      return ConfigurationManager.GetSection("sitecore") as ConfigReader;
  }
  </code></pre>
  
  <p>So...
  Why can't the referenced dll read the app.config through the ConfigurationManager?</p>