Serialisation fails, but without any errors being thrown.

G

Greg

I have a bizarre situation in which serialisation is failing routinely
under a specific condition, and I'm wondering if the details ring a
bell with anyone here.

I have 2 classes that my application serialises before closing down.
One of these classes contains a string field which contains a path to a
file. This is populated from the contents of a text box, which in turn
is populated using an OpenFileFialog object.

Under normal usage, the 2 classes always fail to be serialised.
However, if a path is manually typed into the text box mentioned above,
serialisation works. At the point of serialisation, I've checked that
the field corresponding to the file path is the same, regardless of how
the path was entered into the text box (typed or using an
OpenFileDialog object).

This is absolute madness - why should the fact that an OpenFileDialog
box has been used at some point in the application's lifetime mean
that serialisation fails?

Stepping through the serialisation (done using the BinaryFormatter), I
can't see any obvious problems and certainly no errors are being
thrown.

I'm confident that the OpenFileDialog object is relevant to the
problem as whether it is used or not is the sole user action that
defines whether serialisation works or not.

For what its worth, I use different BinaryFormatter objects for
serialising the two classes (they are local to the method they are
used in).

Please spare me from insanity!

Greg
 
S

Stoitcho Goutsev \(100\)

Greg,

Can you post simple compilable sample the demonstrates the problem and we
can fiddle with.
 
G

Greg

Stoitcho,

Thanks, I sorted it in the end. I was using a relative file path for
the serialisation, and the opening of the openfiledialog box was
changing the working file path.

Regards,

Greg.
 

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