Connecting Tech Pros Worldwide Forums | Help | Site Map

cannot serialize a generic Dictionary

Tim_Mac
Guest
 
Posts: n/a
#1: Jan 12 '06
hi,
i am able to serialize a normal generic List<> no problem. But when i
try to serialize a Dictionary<string,string>, i get an exception as
shown below:

"The type System.Collections.Generic.Dictionary[string, string....] is
not supported because it implements IDictionary"

why is it not straight forward to serialize a dictionary, like it is
with a generic List?
what can i do to serialize it? i looked at Dictionary.GetObjectData
but i got stuck trying to fill in the first parameter
"SerializationInfo" which needs an IFormatter, and i presume is asking
me for a specification for how to serialize it, which i don't think i
should have to do just to do this simple thing!

this is the code i'm using the serialize:
XmlSerializer xs = new XmlSerializer(typeof(Dictionary<string,
string>));
xs.Serialize(fs, pList);

thanks for any help
tim


Closed Thread