473,326 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 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 2015
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ryan Hubbard | last post by:
I've have been trying to serialize an array of objects. I can serialize and set a session variable and retrieve it successfully for a serialize string of any length within the contents of a single...
2
by: Aleksei Guzev | last post by:
Imagine one writing a class library CL1 for data storage. He defines classes ‘DataItem’ and ‘DataRecord’ so that the latter contains a collection of the former. And he derives class ‘IntItem’ from...
1
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I...
10
by: copx | last post by:
I want to save a struct to disk.... as plain text. At the moment I do it with a function that just writes the data using fprintf. I mean like this: fprintf(fp, "%d %d", my_struct.a, my_struct.b)...
1
by: Chris | last post by:
I'm having trouble Serializing a System.Data.DataColumn object. When I try to serialize it, I get the following: System.NotSupportedException: Cannot serialize member...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
4
by: Jason Shohet | last post by:
We are thinking of serializing an object & passing it toseveral functions on web service. This will happen about 35 times as the page loads. The class has about 20 attributes. We're not sure...
2
by: Simon | last post by:
I'm developing a new application and want to use serialization as a way to save my data. But as I add new variables to my classes, how will serializing cope with that? For example, suppose I have...
7
by: fjlaga | last post by:
I have written an Office Add-in for Excel using VB.NET and the .NET 1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I want to add a User Settings/Prefereneces dialog and allow...
12
by: Cagdas Ozgenc | last post by:
Greetings, When directly serializing C++ structures to a file with the standard library functions giving the address of the data and length of structure using the sizeof operator, do I risk...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.