title: Dealing with SerializationExceptions in C#
body: <p>I get a <code>SerializationException: (...) is not marked as serializable.</code> error in the following code:</p>
  
  <pre><code>[Serializable]
  public class Wind
  {
      public MyText text;
      public Size MSize;
      public Point MLocation;
      public int MNumber;
  
      /.../
  }
  
  [Serializable]
  public class MyText 
  {
      public string MString;
      public Font MFont;
      public StringFormat StrFormat;
      public float MySize;
      public Color FColor, SColor, TColor;
      public bool IsRequest;
      public decimal MWide;
  
      /.../
  }
  </code></pre>
  
  <p>and the List to be serialized:</p>
  
  <pre><code> List&lt;Wind&gt; MyList = new List&lt;Wind&gt;();
  </code></pre>
  
  <h3>Code Snippet:</h3>
  
  <pre><code> FileStream FS = new FileStream(AppDomain.CurrentDomain.BaseDirectory + 
                                  "Sticks.dat", FileMode.Create);
   BinaryFormatter BF = new BinaryFormatter();
  
   BF.Serialize(FS, MyList);  
   FS.Close();
  </code></pre>
  
  <p>throws an Exception:</p>
  
  <pre><code>System.Runtime.Serialization.SerializationException was unhandled
    Message="Type 'System.Drawing.StringFormat' in Assembly 'System.Drawing,   
  Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not 
  marked as serializable."
  </code></pre>
  
  <p>How do I solve this problem?</p>