Updating the BinaryFormatter Object Chart

In my object graph, I have something like

[Serializable]
public class Dog 
{
     string _name;
}

and I have all kinds of dog lists and links to dogs.

Since the dog was only a beast at the beginning of the creation of the software, I did not need any base class. Now this need has arisen, and now I would like to have

[Serializable]
public class Dog : Animal
{
    public void Bark() { }
}

[Serializable]
public class Cat : Animal
{
    public void DoTheCatStuff() { }
}

[Serializable]
public class Animal 
{
     string _name;
}

BUT: when I deserialize an OLD archive, I have no dogs. They did not deserialize from the archive at all.

I would like some tips on how to do this. If I need a new class hierarchy and manually copy objects from the old dog to the new TheDog, great, but I would like to avoid it if possible.

EDIT: some .NET gurus, WHY don't I have dogs?

+3
source share
2

; :

, , , , .

, , XML, , , LinqToXml .

0

All Articles