Serializing NameValuePairs

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?
 
J

John Murray

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.
 
N

Nicholas Paldino [.NET/C# MVP]

John,

This isn't completely true. Objects that implement IDictionary are not
XML serializable. Using regular serialization, they serialize just fine.
 
N

Nicholas Paldino [.NET/C# MVP]

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top