title: ConfigurationManager in WPF
body: <p>I have a config file in a wpf project to store the connectionstring.
  But when I try to get AppSettings and ConnectionStrings, I get null.</p>
  
  <p>the WEB.config file is like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      &lt;add name="Trackboard" connectionString="Data Source=(localdb)\v11.0;Initial Catalog=Trackboard;Integrated Security=True;AttachDbFileName=E:\Users\Sean\Workspace\DATABASE\Trackboard.mdf"/&gt;
    &lt;/connectionStrings&gt;
    &lt;appSettings&gt;
      &lt;add key="Trackboard" value="Data Source=(localdb)\v11.0;Initial Catalog=Trackboard;Integrated Security=True;AttachDbFileName=E:\Users\Sean\Workspace\DATABASE\Trackboard.mdf"/&gt;
    &lt;/appSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I tried in several ways:</p>
  
  <pre><code>W1: ConnStr = ConfigurationManager.ConnectionStrings["Trackboard"].ConnectionString;
  W2: ConnStr = ConfigurationManager.ConnectionStrings[0].ConnectionString;
  W3: ConnStr = ConfigurationManager.AppSettings["Trackboard"];
  W4: ConnStr = ConfigurationManager.AppSettings[0];
  </code></pre>
  
  <p>None of them worked.</p>
  
  <p>But this one worked:</p>
  
  <pre><code>ConnStr = @"Data Source=(localdb)\v11.0;Initial Catalog=Trackboard;Integrated Security=True;AttachDbFileName=E:\Users\Sean\Workspace\DATABASE\Trackboard.mdf";
  </code></pre>
  
  <p>(That means I cannot use a config file, which is against my will)
  I need help.</p>