I have a class with an XMLElement of type Message:
public class TimeBlock
{
public TimeBlock()
{
info = new Message();
}
[XmlElement("ReceivedInfo")]
public Message info { get; set; }
}
which is a self-defined class containing XMLElement of type List.
[XmlElement("ReformedLine")]
public List<XCData> reformedBody { get; set; }
where "line" is a string. In the main method I have:
XCData reformedLine = new XCData(line);
timeBlock.info.reformedBody.Add(reformedLine);
But after running it throws the exception of:
System.InvalidOperationException' occurred in System.Xml.dll
How can I solve this? Generally, how should I wrap a part of Data I want to serialize into CDATA (before forming the XML document and having access to the nodes)?