473,503 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serialization of StringDictionary

J.R
I'm getting an error when I attempt to serialize a type StringDictionary,
error suggests type not marked for Serialization, could someone tell me how
to go about this?

Thanks.
Nov 15 '05 #1
3 9882
In short, you can't. The type isn't marked as Serializable and doesn't
implement ISerializable.

As an alternative, you can use a ListDictionary. ListDictionaries are
serializable. Only difference is they take any type of object, not just
strings.

The other alternative is to write a custom string dictionary that is
serializable.

-Rob [MVP]

"J.R" <so*****@somewhere.com> wrote in message
news:Uw***********************@news1.calgary.shaw. ca...
I'm getting an error when I attempt to serialize a type StringDictionary,
error suggests type not marked for Serialization, could someone tell me how to go about this?

Thanks.

Nov 15 '05 #2
J.R.
In addition to Rob's suggestions.

You could manually iterate the StringDictionary in the containing class
adding the items to the SerializationInfo class in the GetObjectData method.
This would assume the containing class implements the ISerializable
interface (in addition to having the SerializableAttribute. I would add a
number of items count before saving the items. So on deserialization I would
know how many items to restore. Just remember the names you use in
SerializationInfo need to be unique, I would probably prefix the items &
count from the StringDictionary with some unique value.

Hope this helps
Jay

"J.R" <so*****@somewhere.com> wrote in message
news:Uw***********************@news1.calgary.shaw. ca...
I'm getting an error when I attempt to serialize a type StringDictionary,
error suggests type not marked for Serialization, could someone tell me how to go about this?

Thanks.

Nov 15 '05 #3
J.R
Thank you kind Sirs, for your prompt and informative responses. Once again,
I've implemented your suggestions and it is working perfectly.

John.

"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
In short, you can't. The type isn't marked as Serializable and doesn't
implement ISerializable.

As an alternative, you can use a ListDictionary. ListDictionaries are
serializable. Only difference is they take any type of object, not just
strings.

The other alternative is to write a custom string dictionary that is
serializable.

-Rob [MVP]

"J.R" <so*****@somewhere.com> wrote in message
news:Uw***********************@news1.calgary.shaw. ca...
I'm getting an error when I attempt to serialize a type StringDictionary, error suggests type not marked for Serialization, could someone tell me

how
to go about this?

Thanks.


Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
7479
by: John | last post by:
Hi! I have a StringDictionary itialized as follows: private void frmICUCalculations_Activated(object sender, System.EventArgs e) { StringDictionary dataDict = new StringDictionary();...
4
3692
by: Sanjay Vyas | last post by:
Sorry, forgot to cross post this one.. This is rather unusual as we would expect any Collection class to implement ICollection interface and furthermore a Dictionary class should implement...
2
4110
by: Wamiq Ansari | last post by:
Hi!, I am trying to add a value to a StringDictionary using its Item Property in C#. However this throws an expection as follows: Cannot implicitly convert type 'Component.TemplateComponent' to...
1
3005
by: Srikanth | last post by:
Hi, I have a StringDictionary object with Key and Value pairs. I have a situation where 1. I have to retrieve the Value for a given Key and 2. I have to retrieve the Key for a given Value. ...
0
2478
by: umhlali | last post by:
I get the following exception when my VB.NET app calls a Java web service that returns an array of objects. The same call works for a single object though. So looks like there is no problem...
2
1311
by: rajmgopal | last post by:
Hi I am using a StringDictionary to store and pass a few string values retrieved from sql server database. I am using these values as inputs to several stored procedures After processing a few...
0
1663
by: Simon Dahlbacka | last post by:
I was trying to use the built in settings management and added a User-scoped setting of type System.Collections.Specialized.StringDictionary I run my application, updated the Settings, did...
0
1439
by: Hans | last post by:
Hello, I was trying to use the built in settings management and added a User-scoped setting of type System.Collections.Specialized.StringDictionary I run my application, updated the...
4
10665
by: Peter K | last post by:
Hi are there any benefits in using StringDictionary over Dictionary<string, string? It appears they achieve the same thing... (I could be wrong of course). thanks, Peter
0
7201
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,...
0
7083
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...
0
7278
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,...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7456
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...
0
3166
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...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.