title: Data contract serialization for object array
body: <p>I have following scenario and I'm unable to find a solution:</p>
  
  <p>I have multiple data contract proxys that are generated through <code>svcutil.exe</code> tool. I'm trying to serialize instance of <code>object[]</code> containing data contract proxy instances. Tried following:</p>
  
  <pre><code>public static string Serialize&lt;T&gt;(T obj)
  {
     StringBuilder sb = new StringBuilder();
     var known = new List&lt;Type&gt;(){typeof(myDataContracClass), typeof(object[])};
     DataContractSerializer ser = new DataContractSerializer(typeof(T), known );
     ser.WriteObject(XmlWriter.Create(sb), obj);
     return sb.ToString();
  }
  </code></pre>
  
  <p>And then using it by:</p>
  
  <pre><code>object[] arrayToSerialize = new object[] { someGuid, myDatacontractProxyInstance};
  var serialized = Serialize(arrayToSerialize);
  </code></pre>
  
  <p>EDIT: (To futher describe my setup)</p>
  
  <p>I have placed following data contract attributes:</p>
  
  <pre><code>[DataContract(Namespace = "http://mynamespace-uri")]
  </code></pre>
  
  <p>in the svcutil.exe's proxy generation I have declared namespace <code>/n:*,My.Custom.Namespace</code>, which causes generated proxies to have different namespace than the data contract class.</p>
  
  <p>Offtopic: Why microsoft ended up with so difficult serialization components?</p>