Serialize Structure


S

Scott Collier

I would like to serialize a custom structure eg.

Private Structure Dog
Dim DogName As String
Dim DogAge As Integer
Dim Fleas As ArrayList
End Structure

I am using a BinaryFormatter() to serialize the data. Each Dog is added to a
HashTable, and then the final HashTable is serialized... well that is the
intention.
Why does it come up with following error : PublicKeyToken=null' is not
marked as serializable

Any help on achieving this task or pointers would be helpful
Scott
 
Ad

Advertisements

G

Guest

Try adding the SerializableAttribute to the structure:
<Serializable()>
Private Structure Dog
Dim DogName As String
Dim DogAge As Integer
Dim Fleas as ArrayList
End Structure

You can mark individual fields as un-serializable with the
NotSerializableAttribute.
 
Ad

Advertisements

S

Scott Collier

Thanks Peter, I didn't think it was going to be that easy - but it worked.

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top