title: ...may not be used in this context...while serialization
body: <p>I've webservice and WebMethod</p>
  
  <pre><code>[webMethod]
  [XMLInclude(typeof(ContractCar[]))
  public object GetObjects(Cars[] cars)
  {
  return Translator.ToObjects(Facade.GetObjects(cars);
  
  }
  
  public static object GetObjects(Cars cars)
  {
  List&lt;Car&gt;  cars =new List&lt;Country(...fillingcollection)
  return cars.ToArray(),
  }
  
  public static object ToObjects(object collection)
  {
  if(collection is Car[])
  {
  return ConvertModelCarsToContractCars(collection),
  }
  
  public ContractCar[]  ConvertModelCarsToContractCars(Cars[] collection)
  {
  ...there is rewriting pool...
  }
  </code></pre>
  
  <p>And I get exception at side of client:</p>
  
  <p>There was an error generating the XML document.</p>
  
  <p>I'm using this function to check collection which I would send to the client and it works.</p>
  
  <pre><code> public static void SerializeContainer(object obj)
          {
              try
              {
                  // Make sure even the construsctor runs inside a
                  // try-catch block
                  XmlSerializer ser = new XmlSerializer(typeof(object));
  
                  TextWriter w = new StreamWriter(@"c:\list.xml");
  
  
                ser.Serialize(w, obj);
                  w.Close();
  
              }
              catch (Exception ex)
              {
                  DumpException(ex);
              }
          }
  </code></pre>
  
  <p><strong>Interesting is when collection has only One element [webmethod] works fine, but when is more it brokes</strong></p>