473,387 Members | 1,553 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,387 software developers and data experts.

Problem w/ Simple Serialization

Hi,

I have a simple class that has a Hashtable. the hashtable has a couple of
key/value pairs where the key is a string and the value is also a strong.

I have [Serializable] at the top of that class.

when I try to serialize it with XmlSerializer, I get only the "class
boundary" but my hashtable member doesn't get serialized. Hashtable is
Serializable, at least that's what the documentation says.

Am I missing something?

Thanks,
Ron
Aug 11 '06 #1
2 1311
There are 2 kinds of Serialization: "Binary" and XML. The [Serializable]
attribute relates to binary serialization, and HashTable cannot be
serialized as XML.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
"Ron M. Newman" <co**********@confideltial.comwrote in message
news:eF**************@TK2MSFTNGP02.phx.gbl...
Hi,

I have a simple class that has a Hashtable. the hashtable has a couple of
key/value pairs where the key is a string and the value is also a strong.

I have [Serializable] at the top of that class.

when I try to serialize it with XmlSerializer, I get only the "class
boundary" but my hashtable member doesn't get serialized. Hashtable is
Serializable, at least that's what the documentation says.

Am I missing something?

Thanks,
Ron

Aug 11 '06 #2
"Ron M. Newman" <co**********@confideltial.comwrote:
I have a simple class that has a Hashtable. the hashtable has a couple of
key/value pairs where the key is a string and the value is also a strong.

I have [Serializable] at the top of that class.

when I try to serialize it with XmlSerializer, I get only the "class
boundary" but my hashtable member doesn't get serialized. Hashtable is
Serializable, at least that's what the documentation says.

Am I missing something?
Yup. Hashtable isn't serializable with XmlSerializer, and XmlSerializer
is a different thing than the [Serializable] attribute.

XmlSerializer deals with hierarchical object trees - it can't handle
cycles etc. It also only works with public read/write properties. It
works with the Xml* attributes in System.Xml.Serialization. You can
implement an interface to create custom serialization of your hashtable
data: IXmlSerializable.

[Serializable] is for use with the types in
System.Runtime.Serialization, and serialization formatters such as
BinaryFormatter and SoapFormatter. It works with private members, and
can handle arbitrary object graphs, so long as all the objects are
serializable.

-- Barry

--
http://barrkel.blogspot.com/
Aug 11 '06 #3

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

Similar topics

0
by: HakonB | last post by:
Hi all I get an exception when trying to deserialize a simple configuration file using XML Serialization. The very long stacktrace can be seen at the bottom of this message. I've see other...
2
by: Carlo, MCP | last post by:
Hello, I'm troubling from months with a serious serialization problem that I'm not able to solve. I try to describe as simply as I can. 1) I have a class tha does something with colors. All...
2
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects"...
1
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two...
5
by: Harold Howe | last post by:
I am having a problem deserializing objects from a library when the following conditions exist: 1- The library is strongly named 2- The serialized file was created with version 1.0 of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...

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.