C# Not able to serialize class with List as property?

There is no problem with your code or the serialization of generics. Uri doesn't have a default constructor and cannot be serialized. Consider changing it to a string and things will work.

If you are only planning on using the XmlSerializer you can remove the Serializable attribute because it isn't used.

There is no problem with your code or the serialization of generics. Uri doesn't have a default constructor and cannot be serialized. Consider changing it to a string and things will work.

If you are only planning on using the XmlSerializer you can remove the Serializable attribute because it isn't used. When I ran your code with the debugger and saw the exception there was an inner exception with an inner exception with an inner exception and so on. Always a good idea to follow that rabbit down the hole when you can.

Thanks , just replaced Uri by string and it worked liked a charm – Pravin Jan 22 '11 at 16:48.

You have to pass extra types that are in xml,to XmlSerializer, in your case Link type. Use this XmlSerializer serializer = new XmlSerializer(typeof(List), new Type {typeof(Link)}).

Copied and pasted this code into my test program and it gives me an InvalidOperationException. Following the chain of inner exceptions the root of the issue is still the Uri without a default constructor. – Ryan Pedersen Jan 22 '11 at 16:32 Yes right, I was about to add that myself.

He should replace Uri with a String. And also have to specify all the extra types that are being deserialized apart from the Batches (in the XmlSerializer ctor). – Vijay Sirigiri Jan 22 '11 at 16:35.

Your own classes must implement a public constructor with no params, for example for class Link you must implement an additional constructor public Link() {}.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions