I want to deserialize a dictionary with datacontractserializer, the xml schema is the following :
C#
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>1a:Key>
a:Value>
....
a:Value>
a:KeyValueOfunsignedByteMyclass>
a:KeyValueOfunsignedByteMyclass>
a:Key>2a: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

VulpesRank #55 · 29.2K reputationPosted Dec 19, 2013, 5:44 AM EST
The resulting XML is:
The console output (as expected) is:
1
2