473,763 Members | 7,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1337
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**********@c onfideltial.com wrote in message
news:eF******** ******@TK2MSFTN GP02.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**********@c onfideltial.com wrote:
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.Seri alization. You can
implement an interface to create custom serialization of your hashtable
data: IXmlSerializabl e.

[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
1620
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 messages related a similar error but none of the solutions suggested are valid in case :/ I have tracked the problem down to the compilation of the temporary DLL that handles the actual serialization. The following commandline (that is one single...
2
1083
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 default values are obviously NOT serializad. Instead, they are serialized when they are different from those of default. Sample: Class ColorClass Private mBackground=Color.White Public Property Background
2
2759
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" and return a complex type "FieldSearchResult". The error message as following : "Cannot assign object of type System.String to an object of type System.String. There is an error in XML document (23, 97)." By the way,I hava written a client in Java...
1
5554
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 other properties... bool error; string lastError; My whole class looks like this... using System;
5
6030
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 assembly 3- I am trying to deserialize from an EXE that references version 2.0 of the assembly 4- Both version 1.0 and 2.0 of the assembly reside in the GAC (no policy redirects exist).
0
9563
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
9386
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
9997
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
9822
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...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
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();...
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.