I\'m trying to run code similar to this:
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
namespace ConsoleA
Here's an untested shady workaround that i tend to use in principle:
private IList myArray;
[XmlIgnore]
public IList MyArray
{
get { return myArray; }
set { myArray = value; }
}
[XmlElement("MyArray")]
public object MyArraySerializable
{
get { return MyArray; }
set { MyArray = value as IList; }
}
This will serialize whatever list you may be using as generic object with a type attribute which will tell the deserializer the actual type of the object, so when that object gets deserialized it should be cast to a IList again. Remember to provide any types that may be assumed by the interface.
I see no reason why any serializer should be unable to serialize such properties. It is not like you actually try to serialize an interface, you try to serialize an object which implements a certain interface (which is not far different from abstract subclassing, some programming languages even solely operate on interfaces).
When the serializer should serialize that object it knows that the object implements that interface, all it really has to do is serialize it and attach the type attribute (like it does if you serialize abstract classes or just super-classes in general).
Now the deserializer looks at the type and can check if that object in fact implements the required interface and then deserialize it to the respective property.