Get connection string from app.config
<p>I'm trying to make this simple call:</p>

<pre><code>DataContext dc = new DataContext(ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString)
</code></pre>

<p>And here's my app.config file:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;configuration&gt;
  &lt;connectionStrings&gt;
    &lt;add name="MyDB" connectionString="Server=STEVEN-PC;Database=MyDB;Trusted_Connection=yes;" /&gt;
  &lt;/connectionStrings&gt;
&lt;/configuration&gt;
</code></pre>

<p>But I'm getting an error: <strong>Object reference not set to an instance of an object.</strong></p>

<p>It can't find the connection string. What am I doing wrong?</p>
