473,616 Members | 2,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Collection Class Serialization

Can anyone point me to a collection class that has
serialization/deserialization with it - preferably in XML.

I know this can't be done with a collection that inherits from
CollectionBase, but I'm hoping someone has another collection class out
there.

Thanks;
Michael
Nov 21 '05 #1
4 1467
Michael,
Can anyone point me to a collection class that has
serialization/deserialization with it - preferably in XML.

This has only one answer. The dataset.

Cor
Nov 21 '05 #2
Michael,

Both arraylist and hashtable can be serialized with a binaryformatter . I
think that arraylist can also be serialized as xml.

I'm surprised that collectionbase is not serializable. Are you sure about
that?

Kerry Moorman
"Michael Rich" wrote:
Can anyone point me to a collection class that has
serialization/deserialization with it - preferably in XML.

I know this can't be done with a collection that inherits from
CollectionBase, but I'm hoping someone has another collection class out
there.

Thanks;
Michael

Nov 21 '05 #3
J L
Strange coincidence...a s a newbie I was trying various things today
and one was serializing both a HashTable and a SortedList. Both can be
serialized to XML via SOAP. In fact, I placed my Person objects (just
a dumb class I created for learning purposes) and was able to
serialize and deserialize the objects. Not sure how I am going to use
it yet but it was cool.

Here is an example of writing:

Dim sl As New SortedList
Dim John As Person
Dim Mary As Person
Dim Joe As Employee ' employee inherits from Person

John.Name = "John"
John.BirthDay = "01/01/2000"
<etc>

sl.Add(John.Bir thDate, John)
sl.Add(Mary.Bir thDate, Mary)
sl.Add(Joe.Birt hDate, Joe)

Dim formatter As New Soap.SoapFormat ter
Dim saveFile As New FileStream

saveFile = File.OpenWrite( "C:\ATest.t xt")
formatter.Seria lize(saveFile, sl)
saveFile.close( )

And here is how to read it:

Dim sl As New SortedList
Dim Formatter As New Soap.SoapFormat ter
Dim readFile As New FileStream
readFile = File.OpenRead(" C:\ATest.txt")
sl = CType(formatter .Deserialize(re adFile), SortedList)

Dim aPerson As Person
Dim dt As Date
For Each dt In sl.Keys
aPerson = Ctype(sl.Item(d t), Person)
MessageBox.Show (aPerson.Name, aPerson.BirthDa te.ToString)
Next

John

On Thu, 24 Mar 2005 00:58:22 -0800, "Michael Rich"
<mr***@michaelr ich.com> wrote:
Can anyone point me to a collection class that has
serializatio n/deserialization with it - preferably in XML.

I know this can't be done with a collection that inherits from
CollectionBase , but I'm hoping someone has another collection class out
there.

Thanks;
Michael


Nov 21 '05 #4
It is serializable and marked as such; however I am having trouble
serializing it using custom serialization because I can't call
mybase.GetObjec tData for it.
"Kerry Moorman" <Ke**********@d iscussions.micr osoft.com> wrote in message
news:3D******** *************** ***********@mic rosoft.com...
Michael,

Both arraylist and hashtable can be serialized with a binaryformatter . I
think that arraylist can also be serialized as xml.

I'm surprised that collectionbase is not serializable. Are you sure about
that?

Kerry Moorman
"Michael Rich" wrote:
Can anyone point me to a collection class that has
serialization/deserialization with it - preferably in XML.

I know this can't be done with a collection that inherits from
CollectionBase, but I'm hoping someone has another collection class out
there.

Thanks;
Michael

Nov 21 '05 #5

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

Similar topics

3
12860
by: jamie_m_ | last post by:
I have a custom collection ... clFile that INHERITS from NameObjectCollectionBase the problem is, when I try to create an xmlserializer instance i get an error You must implement a default accessor on brWAP.clFile because it inherits from ICollectio I must be having a thick day because I dont have a clue what the error message means. (I have written a defaut property called ITEM in the clFile class 'Classes to abstract a FILE entity...
1
3132
by: Brian Orrell | last post by:
I know how to deserialize a collection class that is referenced in a container class as a variable or property using the XmlArray and XmlArrayItem attributes. What I can't for the life of me figure out is how to deserialize a collection class that is the top level element of an xml stream. Hopefully the following example will make sense. The example below compiles and runs, but it doesn't pick up any of the children of the collection...
2
9528
by: Greg | last post by:
I'm writing a class in C# .... I have a collection calls Reports made up of Report objects. I'm trying to deserialize an XML file that looks like : <Reports> <Report> <Title>some title</Title> <Notes> some notes </Notes> </Report> <Report> blah blah blah </Report>
16
2585
by: Ben Hannon | last post by:
Hi, I'm writting a COM Class in VB.NET to be used in a VB6 project (Tired of the VB6 hassles with cloning and serializing an object). All my classes I need cloneable/serializable are now in a VB.NET class that exposes those objects to COM perfectly. However I ran into a problem because some of these objects requires a Collection. When I compile this project with the VB.NET Collection exposed for a property, I get a compile time error...
27
413
by: Craig Buchanan | last post by:
Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string. I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match, but I thought there might be an easier way. Thanks,
3
11750
by: RandomEngineer | last post by:
So here's the challenge... How can a collection (System.Collections.Generic.IList) of some custom type be serialized in a web service using .NET 2.0? Below are the class and the web methods in question. The interesting thing is that at each step of the way, DAL & Biz, the someType class is decorated with the Serializable attribute. And the someTypes collection in the web method is correctly populated with the data after the call to...
4
2768
by: Kyote | last post by:
I'm trying to persist a list of filenames. I've made a custom collection and a FileName class: 'Class to hold file name information Public Class FileNames Public fullName As String Public fileName As String Public fileExtention As String Public filePath As String Public newName As String
1
2137
by: DesperateDan | last post by:
I've got a parent object that is a collection and it in turn is hosting 2 child objects. My searlization has worked perfectly to plan in as much that I wanted to dictate the names of the objects and properties via XMLatrributes with a prefix of "THE_.."....except for the name of the child objects. This should say THE_NEW_Child but instead still persist in saying "NewChild" (Child properties are as planned) What's the solution?
4
1455
by: xke | last post by:
Why the collection property is not included in the ouput serialization ? I have a custom generic collection (implements icollection): Events of objects: Event. Event is a simple class exposing, let's say, one property: name Public Class Event <XmlAttribute("name")_
0
8203
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
8146
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,...
1
8297
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8449
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
7121
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...
1
6097
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
5550
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
4141
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.