I get a SerializationException: (...) is not marked as serializable.
error in the following 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;
/.../
}
and the List to be serialized:
List<Wind> MyList = new List<Wind>();
Code Snippet:
FileStream FS = new FileStream(AppDomain.CurrentDomain.BaseDirectory +
"Sticks.dat", FileMode.Create);
BinaryFormatter BF = new BinaryFormatter();
BF.Serialize(FS, MyList);
FS.Close();
throws an Exception:
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."
How do I solve this problem?