如何反序列化或恢复未完成序列化的二进制序列化字典?
当我使用我的应用程序时,在关闭时,它尝试序列化一个 300 KB 的字典。由于没有磁盘空间,只能写入292 KB。有没有办法成功反序列化其中的内容?
我使用了 BinaryFormatter,如果我丢失了一些元素,这比丢失整个字典要好得多。
当我反序列化时,我得到这个异常:
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 ..."
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 ..."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
分离二进制流确实需要大量有关实现的知识。
BinaryFormatter
是专有的,因此...除非该数据确实有价值,否则认为它丢失可能会更便宜。您可以进行大量的记录,但这并不容易,而且开发时间也不便宜。不过,我并不是说这不能做到。 FWIW,我可以想出对其他一些序列化器执行此操作的方法 - 只是不
BinaryFormatter
。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
.