1
Reply

Deserialize dictionary with datacontractserializer c#

step nopeus

step nopeus

Dec 18 2013 2:41 PM
3.3k

I want to deserialize a dictionary with datacontractserializer, the xml schema is the following :


<
General xmlns="http://schemas.datacontract.org/2004/07/MyProject" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Mydictionary xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <a:KeyValueOfunsignedByteMyclass> <a:Key>1</a:Key> <a:Value> .... </a:Value> </a:KeyValueOfunsignedByteMyclass> <a:KeyValueOfunsignedByteMyclass> <a:Key>2</a:Key> <a:Value> .... </a:Value> </a:KeyValueOfunsignedByteMyclass> </Mydictionary>

But on deserializing, I get this error :

"An item with the same key has already been added."

(referencing KeyValueOfunsignedByteMyclass)

Can someone help me to resolve this problem please?

Thanks



Answers (1)