title: Why is CS0246 "The type or namespace name 'Name' could not be found" C# error so confusing?
body: <p>Here's the scenario. I create a new class library project in Visual Studio, add some classes. Then at some point I decide that I need some class to be marked with <code>System.Runtime.Serialization.DataContractAttribute</code> and I write the following:</p>
  
  <pre><code>[DataContract]
  public class MyDataContractClass {}
  </code></pre>
  
  <p>and when I hit compile I see the following error:</p>
  
  <blockquote>
    <p>error CS0246: The type or namespace name 'DataMember' could not be found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>Okay, the problem is I forgot to add <code>using</code> directive to make the class visible. I add</p>
  
  <pre><code>using System.Runtime.Serialization;
  </code></pre>
  
  <p>to the same file above the class but the problem doesn't go away until I add a reference to <code>System.Runtime.Serialization</code> in the Project Explorer.</p>
  
  <p>This is very confusing. Why do I have to add the same thing two times in different places and <strong><em>see the same error message regardless of which of the two steps I missed</em></strong>?</p>
  
  <p>My question is the following. Is this just <strong><em>badly designed error diagnostics</em></strong> or is there some <strong><em>fundamental reason</em></strong> why missing any of the two above steps leads to the same error emitted by the C# compiler?</p>