title: Can't access information from configuration files when tests have host type "Moles"
body: <p>We are having problems accessing information in .net configuration files (such as app.config and web.config) via unit tests when the unit tests have a host type of "Moles". It's causing quite a few headaches, so I hope someone has an idea on what can be done.</p>
  
  <p>We're using Visual Studio 2010, and I believe we've tried this on a machine with VS 2010 SP1 installed, and machine without SP1 installed, as well as trying it on 32 bit and 64 bit machines.</p>
  
  <p>I've taken the liberty of reducing the test to its simplest terms. The problem can be recreated by composing a unit testing project consisting of the following two files, and running the test after uncommenting the only commented line. The test works without a host type, but when you introduce Moles as a host type, the null assertion in the test fails. We are not sure why.</p>
  
  <p>First, the configuration file App.config:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      &lt;add name="Connection" connectionString="Something" /&gt;
    &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Next, the test class containing a single test:</p>
  
  <pre><code>namespace TestProject
      {
      using System.Configuration;
      using Microsoft.VisualStudio.TestTools.UnitTesting;
  
      [TestClass]
      public class UnitTest
          {
  
          [TestMethod]
          //[HostType("Moles")]
          public void TestMethod()
              {
              var data = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
              Assert.IsNotNull(data.ConnectionStrings.ConnectionStrings["Connection"]);
              }
  
          }
  
      }
  </code></pre>
  
  <p>I would be grateful if anyone could offer any insight.</p>
  
  <p>Thanks very much,</p>
  
  <p>Nick</p>