title: How does one serialize an XDocument object?
body: <p>I want to serialize an <code>XDocument</code> object. I wrote this code.</p>
  
  <pre><code>        XDocument signup_xml_file = new XDocument(
              new XDeclaration("1.0", "utf-8", "yes"),
              new XComment("signup_xml_file"),
              new XElement("Student",
                  new XElement("univ_id", univ_id),
                  new XElement("personal_id",personal_id),
                  new XElement("user_name", user_name)));
          client.Connect(host_name, port);
          //connect to the server .
          bf.Serialize(client.GetStream(), signup_xml_file); // serialize the signup_xml_file
  </code></pre>
  
  <p>I get the following exception when attempting to serialize the <code>XDocument</code>.  Is there any way to make the <code>XDocument</code> class Serializable, or is there another way to send my <code>XDocument</code>?</p>
  
  <blockquote>
    <p>Type 'System.Xml.Linq.XDocument' in Assembly 'System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.</p>
  </blockquote>