title: c# TimeZoneInfo serialization
body: <p>I'm have a bit of a problem with serializing TimeZoneInfo object. I was trying to use TimeZoneInfo variable in data contract for WCF service but the serialization was failing. So i wrote this little piece of code to test the serialization. Here's a what i do:</p>
  
  <pre><code>        var fileName = "tmp.xml";
          var tz = TimeZoneInfo.Local;
          var dataSer = new DataContractSerializer(typeof(TimeZoneInfo));
  
          try
          {
              using (var xml = new FileStream(fileName, FileMode.Create))
              {
                  dataSer.WriteObject(xml, tz);
              }
          }
          catch (Exception e)
          {
              Console.WriteLine(e.Message);
          }
  </code></pre>
  
  <p>Now, when i call WriteObject method it throws an exception:</p>
  
  <blockquote>
    <p>Type 'System.TimeZoneInfo+AdjustmentRule[]' with data contract name 'ArrayOfTimeZoneInfo.AdjustmentRule:http://schemas.datacontract.org/2004/07/System' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.</p>
  </blockquote>
  
  <p>If i attempt to add
  [KnownType(typeof(System.TimeZoneInfo.AdjustmentRule[]))] to the class i get the same error. And if i add this line to my data contract interface i get compile error:</p>
  
  <blockquote>
    <p>Error  1 'System.TimeZoneInfo.AdjustmentRule' is inaccessible due to its protection level  </p>
  </blockquote>
  
  <p>And according to the documentation TimeZoneInfo class implements ISerializable so it should serialize by default.</p>
  
  <p>Can anyone tell me what i'm doing wrong here? I would appreciate any help.</p>
  
  <p>Thanks. </p>