title: Compilation errors in Reference.cs after adding a Service Reference caused by multi-part namespace
body: <p>I hit this weird namespace issue when adding my first 'Service Reference' to a client project in Visual Studio 2010.</p>
  
  <p>If my project's default namespace uses two or more parts, e.g. <code>MyCompany.MyApp</code> then when adding a Service Reference a Reference.cs file is created containing the namespace <code>MyCompany.MyApp.ServiceReferenceName</code> with a lot of auto-gen code with fully qualified names, e.g. <code>System.SerializableAttribute</code>, <code>System.Runtime.Serialization.DataContractAttribute</code>.</p>
  
  <p>The Reference.cs file will be full of compilation errors because the compiler starts treating the System namespace as sub member of the <code>MyCompany.MyApp</code> namespace. You get an awful lot of errors along the lines of: </p>
  
  <blockquote>
    <p><code>The type or namespace name 'Runtime' does not exist in the namespace 'MyCompany.MyApp.System'...</code></p>
  </blockquote>
  
  <p>If I amend the namespace at the top of the Reference.cs file to something simple, e.g. <code>MyCompanyMyApp.ServiceRefernceName</code> then the compiler behaves and recognises the System namespace references as decleration of .net's System namespace.</p>
  
  <p>I'm using a different workaround for now as I really want to keep my multi-part namespaces. My current alternative is to append <code>global::</code> in front of the System namespace references to force the complier to do the right thing. In fact, if the 'Add Service Reference' wizard uses T4 templates I may just amend those to embed my workaround at the source.</p>
  
  <h3>Questions</h3>
  
  <p>I'd really like to understand what's going on here and why a multi-part namespace causes this issue. Presumably there's more to namespaces than I thought. Secondly, would really like to work out a better solution than performing a global Find/Replace every time I add a Service Reference or mucking around with some T4 templates.</p>