I am new to serialization, and I canβt understand for my whole life how to fix this exception that I get ...
I have an object that has the following structure
[XmlRoot("MaxCut2")]
public class MaxCut2File : IFile
{
public MaxCut2File()
{
MyJob = new Job();
Job.Reference = "MyRef";
}
[XmlElement("JobDetails", typeof(Job))]
public IJob MyJob
{
get;
set;
}
}
Inner surface...
public interface IJob
{
string Reference { get; set; }
}
And class
[Serializable()]
public class Job : IJob
{
[XmlElement("Reference")]
public string Reference { get; set; }
}
When I try to serialize an instance of a MaxCut2File object, I get an error
{"Cannot serialize member 'MaxCut2File.MaxCut2File.MyJob' of type 'MaxCut2BL.Interfaces.IJob', see internal exception for more details." } "There was an error reflecting the type" MaxCut2File.MaxCut2File ".
However, if I change my MyJob property from IJob type to job type, it works fine ...
Any ideas?
source
share