title: XmlSerializer, There was an error generating the XML document
body: <pre><code>        XmlSerializer formatter = new XmlSerializer(typeof(List&lt;Objects.PIP&gt;));
  
          **MemoryStream stream = new MemoryStream(new byte[1024]);**
  
          formatter.Serialize(stream, Repository.GlobalRepository.PIPInformation);
  
          byte[] bt = stream.ToArray();
          foreach (Communication.Client Client in server.ClientList)
          {
              Client.SendMessage(bt);
              
          }
          stream.Flush();
  </code></pre>
  <p>I get an error in stared line as:</p>
  <blockquote>
  <p>There was an error generating the XML document.</p>
  <p>InnerException {&quot;Memory stream is not expandable.&quot;}</p>
  </blockquote>
  <pre><code>PIP Class
  
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using ObjectLibrary.Model;
  using System.Xml.Serialization;
  
  namespace PIPServer.Objects
  {
  
  [XmlRoot(Namespace = &quot;urn:my-namespace&quot;)]
  public class PIP
  {
      private long pipID;
  
      public long PipID
      {
          get { return pipID; }
          set { pipID = value; }
      }
  
      private CurrencyPair currencyPair;
  
      public CurrencyPair CurrencyPair
      {
          get { return currencyPair; }
          set { currencyPair = value; }
      }
      ...............
   }
  }
  </code></pre>
  <p>What am i doing wrong?
  Also is my method to convert Stream to byte array correct?  [Answered]</p>