I created a class
[Serializable]
public class clsCategories
{
public static List<infoCategories> listCategories = new List<infoCategories>();
public void serialize()
{
BinaryFormatter bf = new BinaryFormatter();
FileStream fs = new FileStream("categories.dat", FileMode.Create);
bf.Serialize(fs, listCategories);
fs.Close();
}
[Serializable]
public class infoCategories
{
public PictureBox img { get; set; }
public Label lbl { get; set; }
}
}
Now when calling this method...
private void btnDone_Click(object sender, EventArgs e)
{
objCategories.serialize();
this.Hide();
}
I got this error:
An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional information: Type 'System.Windows.Forms.PictureBox' in Assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
Where am i mistaking?