title: Choose 'using' namespace at runtime
body: <p>I have a web service client application that connects to a 3rd party's web service.  The 3rd party has updated their web service so now my client app fails with SOAP exceptions.  Unfortunately, I can't simply update my app to work with the new web service since some of my users will still be using the old web service.  So basically I'd like to be able to work with either version of the web service using a single version of my client app.</p>
  
  <p>Since Visual Studio generates a bunch of code that I compile against when a web reference is added, I now have two files: one generated for each version of the web service.  Both of the APIs are actually identical, it is just the underlying SOAP messages that seem to have changed.  I've put each of these generated files into their own namespace to avoid collisions.  So now I'd like to be able to choose which namespace to use at runtime (based on a config parameter).</p>
  
  <p>For example:</p>
  
  <pre><code>if (useOldVersion)
      using OldVersionNamespace;
  else
      using NewVersionNamespace;
  </code></pre>
  
  <p>Obviously, this would never work since there would be no way to compile the code that references elements in this namespace.  Is there an easy way to deal with this issue?  Maybe I could use reflection to do what I need at runtime?</p>
  
  <p>The only thing I can really think of would be to literally copy/paste my current code into two different files, the only difference being which namespace is used at the top.  This seems like a really bad idea though.</p>