TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
wcheetham
NA
1
0
XmlSerialization
Nov 11 2003 2:58 PM
Hi all, I'm having some problems serializing a class that contains a collection. Creating the TestClass below and then calling its Serialize method throws the error: There was an error reflecting 'TestApp.TestClass' If I use place an [XmlIgnore] over the TheDeliveryList property it works fine. Another option may be to implement the IXmlSerializable interface but I was hoping that this would not be necessary. Any help would be much appreciated. public class TestClass { private DeliveryList deliveryList; private int testClassID; public TestClass(){ deliveryList = new DeliveryList(); Delivery del = new Delivery(); del.DeliveryID="1"; deliveryList.Add(del); del = new Delivery(); del.DeliveryID="2"; deliveryList.Add(del); } public int TestClassID{ get{return testClassID;} set{testClassID=value;} } [XmlArray("Deliveries")] [XmlArrayItem("Delivery", typeof(Delivery))] public DeliveryList TheDeliveryList{ get{return deliveryList;} set{deliveryList=value;} } public string Serialize(){ XmlSerializer xmlSer = new XmlSerializer(typeof(TestClass)); StringWriter sr = new StringWriter(); xmlSer.Serialize(sr,this); return sr.ToString(); } } public class Delivery{ private string deliveryID; public string DeliveryID{ get{return deliveryID;} set{deliveryID=value;} } } public class DeliveryList : CollectionBase{ public int Add(Delivery del){ return List.Add(del); } }
Reply
Answers (
0
)
Sending of Image over Socket Connection
ofstream equivalent in C#