help with serializing

  • Thread starter Thread starter Tom L
  • Start date Start date
T

Tom L

I have some custom created objects I'm trying to serialize.

The first, is a general class, my CustomerAddress class. This class is
simple and contains a variety of properties. The class starts off like:
<Serializable()> _
Public Class CustomerAddress
I can serialize this class no problem. My next class is CustomerAddresses

<Serializable()> _
Public Class CustomerAddresses
Inherits System.Collections.CollectionBase
This will not serialize. This class has only 1 property, the Item property
which returns CustomerAddress.

Is there a rule, best practice, or just a RIGHT way to allow this to work.
I have multiple needs to serialize the data - from XML serialization to
dealing with streams - and my objects
I can post up detailed code if necessary - but perhaps someone can explain
what allows serialization to work with collections?

The next level up in the object model is Customer, as a customer can have
mutliple addresses. Of course, I will want to serialize customer. One
thing I've tried, which works, is in Customer making my addresses collection
a CustomerAddress() array. This allowed the serialization to work right.
However, that means in the order entry app, and all other apps, I'd have to
change everything to support a new structure - just think of enumerating
thru the collection vs having to do the same for the object array. <sigh>

Thanks in advance!
 
Tom L said:
I have some custom created objects I'm trying to serialize.

The first, is a general class, my CustomerAddress class. This class is
simple and contains a variety of properties. The class starts off like:
<Serializable()> _
Public Class CustomerAddress
I can serialize this class no problem. My next class is CustomerAddresses

<Serializable()> _
Public Class CustomerAddresses
Inherits System.Collections.CollectionBase
This will not serialize. This class has only 1 property, the Item
property which returns CustomerAddress.

Is there a rule, best practice, or just a RIGHT way to allow this to work.
I have multiple needs to serialize the data - from XML serialization to
dealing with streams - and my objects
I can post up detailed code if necessary - but perhaps someone can explain
what allows serialization to work with collections?

The next level up in the object model is Customer, as a customer can have
mutliple addresses. Of course, I will want to serialize customer. One
thing I've tried, which works, is in Customer making my addresses
collection
a CustomerAddress() array. This allowed the serialization to work right.
However, that means in the order entry app, and all other apps, I'd have
to change everything to support a new structure - just think of
enumerating thru the collection vs having to do the same for the object
array. <sigh>

Thanks in advance!
I would like to follow the solution to this post. Would you mind letting me
know when someone posts an answer?
Thanks
 
Tom L said:
I have some custom created objects I'm trying to serialize.

The first, is a general class, my CustomerAddress class. This class is
simple and contains a variety of properties. The class starts off like:
<Serializable()> _
Public Class CustomerAddress
I can serialize this class no problem. My next class is CustomerAddresses

<Serializable()> _
Public Class CustomerAddresses
Inherits System.Collections.CollectionBase
This will not serialize. This class has only 1 property, the Item
property which returns CustomerAddress.

Is there a rule, best practice, or just a RIGHT way to allow this to work.
I have multiple needs to serialize the data - from XML serialization to
dealing with streams - and my objects
I can post up detailed code if necessary - but perhaps someone can explain
what allows serialization to work with collections?

The next level up in the object model is Customer, as a customer can have
mutliple addresses. Of course, I will want to serialize customer. One
thing I've tried, which works, is in Customer making my addresses
collection
a CustomerAddress() array. This allowed the serialization to work right.
However, that means in the order entry app, and all other apps, I'd have
to change everything to support a new structure - just think of
enumerating thru the collection vs having to do the same for the object
array. <sigh>

Thanks in advance!
This might be reason: do you have any events? these should not be serialized
 
Back
Top