List<KeyValuePair<string, dynamic>> serialization

405 Views Asked by At

When I try to serialize the instance of class (which has List<KeyValuePair<string, dynamic>>). I get error:

System.Runtime.Serialization.SerializationException: Unsupported type 'System.String' encountered. Perhaps you need to mark it [Serializable] or define a custom serializer for it?

When I make that List as [NonSerialized] all works okay. What do you think about it. How can I fix it? I think this error because i have dynamic type.

1

There are 1 best solutions below

3
On

This works for me. Dictionary<string, dynamic> kvp = new Dictionary<string, dynamic>(); Not sure why you would use a List<KeyValuePair> anyways.