Serializing NameValuePairs

  • Thread starter Thread starter INeedADip
  • Start date Start date
I

INeedADip

I need to store some sort of Name-Value collection in the Application State.

I keep trying different ones, but it errors out saying that they are not
serializable. Do I need to write my own or is there one in the Framework
that is serializable?

I've tried NameValueCollection, Dictionairy<string,string>,
StringDictionairy, etc (you know...everything that implements IDictionairy
and can't be serialized)

What type does everyone else use that can be serialized?
 
Objects that implement IDictionary are not serializable....

Typically what I do is mark the field as not serializable and then
implement a property with a get/set that takes an array value, parses
each item into it's name/value component and inserts them into the
IDictionary based field.
 
John,

This isn't completely true. Objects that implement IDictionary are not
XML serializable. Using regular serialization, they serialize just fine.
 
Actually, the three classes that you mentioned are ALL serializable.
Are you sure it is these instances, or is it something else that you are
trying to store in the application state?
 
Back
Top