title: Serialize HttpWebRequest
body: <p>I try to send HttpWebRequest by Socket and when I want to Serialize it,
  I get this Exception:</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
        Additional information: Type 'System.Net.WebRequest+WebProxyWrapper' in Assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.</p>
  </blockquote>
  
  <p>This is My Code:</p>
  
  <pre><code> [Serializable()]
  
  class BROWSER
  {
      HttpListener Response = null;
      HttpListenerContext context = null;
      HttpListenerRequest request = null;
      HttpListenerResponse response = null;
      public HttpWebRequest Webrequest = null;
      public WebResponse Webresponce = null;
      string responseString = null; 
      //when my Webrequest is ready ...
        public void SendToProxyServer(HttpWebRequest Webrequest)
      {
          byte[] SndData;
          S_RSocket sock = new S_RSocket();
          SndData = Serializ.seryaliz(this.Webrequest);
          sock.Send(SndData);
          this.responseString = sock.res;
  
      }
  </code></pre>
  
  <p>and My Serialize Class : </p>
  
  <pre><code>abstract class Serializ
   {
     #region Filds
     static MemoryStream ms = null;
     static BinaryFormatter formatter = null;
     #endregion
     #region Methods
     public static byte [] seryaliz(object obj)
     {
         ms = new MemoryStream();
         formatter = new BinaryFormatter();
         formatter.Serialize(ms, obj);
         ms.Position = 0;
         String tmp = null;
         StreamReader sr = new StreamReader(ms);
         tmp = sr.ReadToEnd();
         ms.Position = 0;
         sr.Close();
         ms.Close();
         return Encoding.ASCII.GetBytes(tmp);
     }
     public static object DEseryaliz(byte [] Data)
     {
         object obj = new object();
         formatter = new BinaryFormatter();
         ms = new MemoryStream(Data);
         ms.Position = 0;
         obj=(object)formatter.Deserialize(ms);
         ms.Close();
         return obj;
  
     }
     #endregion 
   }
  </code></pre>
  
  <p>I am Setting my Class as Serializable() but it was not working.</p>
  
  <p>Where is the problem?</p>