471,305 Members | 1,135 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 software developers and data experts.

Serializing NameValuePairs

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?
Jan 20 '06 #1
5 1955
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.

INeedADip wrote:
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?

Jan 20 '06 #2
I just wrote my own collection that's serializable. It works sweet.

Steve

"INeedADip" <IN*******@gmail.com> wrote in message
news:eQ**************@TK2MSFTNGP10.phx.gbl...
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?

Jan 20 '06 #3
Could you give me a small example so I know where to start?
Jan 20 '06 #4
John,

This isn't completely true. Objects that implement IDictionary are not
XML serializable. Using regular serialization, they serialize just fine.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"John Murray" <jm*****@pluck.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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.

INeedADip wrote:
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?

Jan 21 '06 #5
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?

"INeedADip" <IN*******@gmail.com> wrote in message
news:eQ**************@TK2MSFTNGP10.phx.gbl...
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?

Jan 21 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Aleksei Guzev | last post: by
1 post views Thread by Ivo Bronsveld | last post: by
10 posts views Thread by copx | last post: by
1 post views Thread by Chris | last post: by
2 posts views Thread by Tobias Zimmergren | last post: by
4 posts views Thread by Jason Shohet | last post: by
2 posts views Thread by Simon | last post: by
7 posts views Thread by fjlaga | last post: by
12 posts views Thread by Cagdas Ozgenc | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.