title: Configure web reference VS 2010 for different environments
body: <p>I have a legacy project, which has several web references and I would like to configure different endpoints depending on the environment (local, dev, staging, production). </p>
  
  <p>I have read this <a href="http://www.codeproject.com/Articles/12317/How-to-make-your-Web-Reference-proxy-URL-dynamic" rel="nofollow">article</a>, but VS is using <code>Settings.settings</code> and applicationSettings instead of <code>appSettings</code>, so instead of using</p>
  
  <pre><code>this.Url = System.Configuration.ConfigurationSettings.AppSettings["foo_Api"]
  </code></pre>
  
  <p>is using <code>this.Url = global::foo.Properties.Settings.Default.foo_Api;</code></p>
  
  <p>My app.config look like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;configSections&gt;
          &lt;sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" &gt;
              &lt;section name="foo.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
          &lt;/sectionGroup&gt;
      &lt;/configSections&gt;
      &lt;applicationSettings&gt;
          &lt;foo.Properties.Settings&gt;
              &lt;setting name="foo_Api" serializeAs="String"&gt;
                  &lt;value&gt;http://myserver/server/Api.asmx&lt;/value&gt;
              &lt;/setting&gt;
          &lt;/foo.Properties.Settings&gt;
      &lt;/applicationSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I have read about configuring with <code>machine.config</code>, but that doesn't work in my case as there are different environments in the same machine. Changing the Url property at runtime isn't the best solution either as I would need to change all the usages of the web reference.</p>
  
  <p>Ideally I would like to use <code>appSettings</code> so I can put a local.config to override the values of the endpoint, but if there is a simple way of overriding the values of <code>applicationSettings</code> is fine too.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This a dll project. Don't know if this may affect somehow.</p>