J
John Dann
I've got a VB2005 program that persists some data structures by
serializing to a disk file and then reading this file whenever the
program restarts.
I tend to 'stage' my program development by creating a new project
every so often and copying the files from the previous project version
into the new project. (So I have an intact previous version of the
project even if the new version goes off in a direction that
ultimately proves unsuccessful.)
This approach normally works well but is giving me a problem with the
serialized file with a DirectCast error whenever I've just created a
new project. The relevant line of code is:
MyObject = DirectCast(bf.Deserialize(fs), MyObjectType)
where bf is the binary formatter and fs is a defined filestream.
If the previous project version was named say Project500 and the new
one is Project600 then the error on trying to start Project600 for the
first time is:
'Cannot cast Project500.MyObject to Project600.MyObject'
Presumably the serialized object has its parent project name embedded
in its binary structure and objects to being deserialized into a
nominally different project.
Is there any way of working around this?
serializing to a disk file and then reading this file whenever the
program restarts.
I tend to 'stage' my program development by creating a new project
every so often and copying the files from the previous project version
into the new project. (So I have an intact previous version of the
project even if the new version goes off in a direction that
ultimately proves unsuccessful.)
This approach normally works well but is giving me a problem with the
serialized file with a DirectCast error whenever I've just created a
new project. The relevant line of code is:
MyObject = DirectCast(bf.Deserialize(fs), MyObjectType)
where bf is the binary formatter and fs is a defined filestream.
If the previous project version was named say Project500 and the new
one is Project600 then the error on trying to start Project600 for the
first time is:
'Cannot cast Project500.MyObject to Project600.MyObject'
Presumably the serialized object has its parent project name embedded
in its binary structure and objects to being deserialized into a
nominally different project.
Is there any way of working around this?