views:

253

answers:

1

When I used my app, on close, it tried to serialize a dictionary that's 300 KB. Because of no disk space, it could only write 292 KB. Is there a way to successfully deserialize whatever is in there?

I used BinaryFormatter and if I lose some elements that's way better than losing the whole dictionary.

When I deserialize I get this exception:

 e.Message "The input stream is not a valid binary format. The starting contents (in bytes) are: 20-01-20-20-20-FF-FF-FF-FF-01-20-20-20-20-20-20-20 ..."
+2  A: 

Picking apart binary streams really needs a lot of knowledge about the implementation. BinaryFormatter is proprietary, so... unless that data is really valuable, it might be cheaper to consider it lost. You could do a lot of scrobbling, but it won't be easy, and dev time isn't cheap.

I'm not saying it can't be done, though. FWIW, I can think of ways of doing this for some other serializers - just not BinaryFormatter.

Marc Gravell
Thanks Marc. What do you mean by scrobbling? You mean like using regex? I see the info I need in ascii format inside that I could use to extract them and then add it to a new file using regex, but not sure if it would be reliable?Also when you said it's proprietary, you mean code wise? You can see how they did it using the reflector, right?Also which serializers would make this possible? Xml? (Although they don't support dictionaries)
Joan Venge
By "scrobbling" I just mean messy work. Yes, you could use reflector; I'm not sure that makes it much easier. Most text formats would be easy enough to truncate; likewise a few binary that have open formats.
Marc Gravell