title: DataContractSerializer namespace for derived class does not match specified in attribute
body: <p>I'm expecting XML output as follows:</p>
  
  <pre><code>&lt;MyBase type="MyDerived"
          xmlns="http://www.mynamespace.com/MySchema" /&gt;
  </code></pre>
  
  <p>Instead, my actual output is as follows:</p>
  
  <pre><code>&lt;MyBase i:type="MyDerived"
          xmlns="http://www.mynamespace.com/MySchema"
          xmlns:i="http://www.w3.org/2001/XMLSchema-instance" /&gt;
  </code></pre>
  
  <p>I'm using the following class definitions to attempt to generate my expected output:</p>
  
  <p>MyBase.cs</p>
  
  <pre><code>namespace MyProject
  {
      [KnownType(typeof(MyDerived))]
      [DataContract(Namespace = MyBase.Namespace)]
      public abstract class MyBase 
      {
          public const string Namespace = "http://www.mynamespace.com/MySchema";
      }
  }
  </code></pre>
  
  <p>MyDerived.cs</p>
  
  <pre><code>namespace MyProject.Events
  {
      [DataContract(Namespace = MyBase.Namespace)]
      public sealed class MyDerived : MyBase {}
  }
  </code></pre>
  
  <p>And I'm using the following serialization code:</p>
  
  <pre><code>var knownTypes = new Type[]
  {
      typeof(MyDerived)
  };
  
  var xmlDictionary = new XmlDictionary(1);
  var settings = new DataContractSerializerSettings();
  settings.KnownTypes = knownTypes;
  settings.RootNamespace = xmlDictionary.Add(MyBase.Namespace);
  
  serializer = new DataContractSerializer(typeof(MyBase), settings);
  
  var actual = String.Empty;
  
  using (var memoryStream = new MemoryStream())
  {
      serializer.WriteObject(memoryStream, new MyDerived());
  
      memoryStream.Position = 0;
  
      using (var streamReader = new StreamReader(memoryStream))
      {
          actual = streamReader.ReadToEnd();
      }
  }
  </code></pre>
  
  <p>I'm not sure why it's using the <code>XMLSchema-instance</code> namespace for my derived object instead of the namespace I've specified to use. I've spent over an hour digging around StackOverflow, Google, and MSDN trying to figure out what I'm doing wrong, but I must be missing it. It seems so close, it must be a simple mistake.</p>
  
  <p>Is this a problem with my class structure, or am I misapplying attributes in some way?</p>
  
  <p>How can I get my expected output?</p>