473,695 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 NameValueCollec tion, Dictionairy<str ing,string>,
StringDictionai ry, etc (you know...everythi ng that implements IDictionairy
and can't be serialized)

What type does everyone else use that can be serialized?
Jan 20 '06 #1
5 2024
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 NameValueCollec tion, Dictionairy<str ing,string>,
StringDictionai ry, etc (you know...everythi ng 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*******@gmai l.com> wrote in message
news:eQ******** ******@TK2MSFTN GP10.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 NameValueCollec tion, Dictionairy<str ing,string>,
StringDictionai ry, etc (you know...everythi ng 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.co m
"John Murray" <jm*****@pluck. com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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 NameValueCollec tion, Dictionairy<str ing,string>,
StringDictionai ry, etc (you know...everythi ng 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*******@gmai l.com> wrote in message
news:eQ******** ******@TK2MSFTN GP10.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 NameValueCollec tion, Dictionairy<str ing,string>,
StringDictionai ry, etc (you know...everythi ng 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
3271
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 script. $_SESSION = serialize($b); // strlen($a) = 120,011 print unserialize($_SESSION) But if I set a session variable and then try to access it on another
2
3293
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 ‘DataItem’ public class DataItem { public DataItem() {}
1
2083
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 created a couple of objects and serializing it into XML based upon the schema works perfectly. The XML / Schema looks something like this:
10
8284
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) This way I have to write another "serializing" function for every new kind of struct I want to write, though. Is there a way to write functions that can write/read any struct to/from plain text format in a portable way?
1
5400
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 System.ComponentModel.MarshalByValueComponent.Site of type System.ComponentModel.ISite because it is an interface. I tried a number of workarounds without sucess:
2
3517
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: + More ways to contact me __________________________________________________________________
4
1673
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 on the impact serializing something has on an asp.net page rendering, compared to say, hitting the db or something like that. THanks Jason Shohet
2
1337
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 a class called Point which has 2 variables X and Y. I save a few jobs (by serializing), and then enhance my application by adding a Z variable. How will serializing behave when loading those jobs that were created before Z was added?
7
2822
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 the user to specify some settings and I need to persist these settings between runs. I made a serializable class which uses the BinaryFormatter to serialize/deserialize the setttings. Serialization works great. However, when I try to...
12
4914
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 portability because of different compilers packing structures into different sizes or components of this structure to different address boundaries (for example placing in multiples of 4 on a 32bit system)? Once the file is serialized, does the same...
0
8656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8590
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9140
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9005
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8845
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7693
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5848
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4351
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.