Very short question:
Why does this class(TCtsPageAdmin) have to be marked [Serializable]?
I'm just trying to serialize a
List<TCtsPage>
TCtsPage class is marked properly.
If I mark TCtsPageAdmin properly with the [Serializable] attribute, then the error moves up the hierarchy -> the object that consumes a TCtsPageadmin object will be the target of the error.
Error:
SaveToFile failed:
Type 'Lrj.Cts.Admin.TCtsPageAdmin' in Assembly 'LrjCtsAdmin, Version=1.0.1.2,
Culture=neutral, PublicKeyToken=null' is not marked as serializable.
[CLSCompliant(true)]
public sealed class TCtsPageAdmin : ILrjObj
{
...
public void SaveToFile(bool aUsePagePath = true)
{
String aFileName;
List<TCtsPage> lst = GetPages("*");
aFileName = aUsePagePath ? Path.Combine(PagePath, "pages.dat") :
"pages.dat";
BinaryFormatter binForm = new BinaryFormatter();
try
{
using (Stream fStream = new FileStream(aFileName, FileMode.Create,
FileAccess.Write, FileShare.None))
{
binForm.Serialize(fStream, lst);
OnSavedToFile(
new InfoEventArgs(
String.Format("SaveToFile succeeded.\n{0}", aFileName)));
}
}
catch (Exception ex)
{
OnSaveToFileFailed(
new InfoEventArgs(
String.Format("SaveToFile failed: \n{0}", ex.Message)));
}
}
...
}