GenericList Sample

Back to summary

Source

using System.Collections.Generic;

namespace XmlSerializersTest.Samples
{
    [Title("Generic list")]
    public class GenericList
    {
        public List<string> Strings { get; set; }
    }
}

XAML Serializer

System.InvalidOperationException: Cannot serialize a generic type 'System.Collections.Generic.List`1[System.String]'.
   at System.Windows.Markup.Primitives.MarkupWriter.VerifyTypeIsSerializable(Type type)
   at System.Windows.Markup.Primitives.MarkupWriter.WriteItem(MarkupObject item, Scope scope)
   at System.Windows.Markup.Primitives.MarkupWriter.WriteItem(MarkupObject item, Scope scope)
   at System.Windows.Markup.Primitives.MarkupWriter.WriteItem(MarkupObject item)
   at System.Windows.Markup.Primitives.MarkupWriter.SaveAsXml(XmlWriter writer, MarkupObject item)
   at System.Windows.Markup.Primitives.MarkupWriter.SaveAsXml(XmlWriter writer, Object instance)
   at System.Windows.Markup.XamlWriter.Save(Object obj, XmlWriter xmlWriter)
   at XmlSerializersTest.Serializers.XamlSerializer.Serialize(Object obj, XmlWriter writer) in C:\Ivan\dev\XmlSerializersTest\XmlSerializersTest\Serializers\XamlSerializer.cs:line 13
   at XmlSerializersTest.SampleProcessor.SerializeToString(Object obj, IXmlSerializer serializer) in C:\Ivan\dev\XmlSerializersTest\XmlSerializersTest\SampleProcessor.cs:line 162
   at XmlSerializersTest.SampleProcessor.RecordSerializationResults(Object obj, IXmlSerializer serializer) in C:\Ivan\dev\XmlSerializersTest\XmlSerializersTest\SampleProcessor.cs:line 115

Deserialization skipped