title: ConfigurationManager keeps getting Machine.config connection string
body: <p>I have a c# assembly that uses the app.config to store its database connection string. When debugging the application I noticed that the connection to the database kept failing because the ConfigurationManager kept returning the machine.config connection string:</p>
  
  <p>data source=.\SQLEXPRESS; Integrated Security;....</p>
  
  <p>I added <code>&lt;clear/</code>> before my connection string in the app.config and it fixed the issue on my dev machine. The problem returned when I deployed it to production. Can someone tell me how I can stop the machine.config connection string from being used?</p>
  
  <pre><code>SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[0].ConnectionString);
  
  &lt;connectionStrings&gt;
      &lt;clear/&gt;
      &lt;add name="VersionConnectionString"
       connectionString=" Data Source=localhost;Initial Catalog=VersionInfo;User ID=user;Password=password"         
       providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>UPDATE</p>
  
  <p>The following still gives me the machine.config connection string?!</p>
  
  <pre><code> Configuration appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
                  string dllConfigData =
                      appConfig.ConnectionStrings.ConnectionStrings[0].ConnectionString;
  </code></pre>