如何反序列化或恢复未完成序列化的二进制序列化字典?

发布于 2024-08-08 21:07:36 字数 344 浏览 3 评论 0原文

当我使用我的应用程序时,在关闭时,它尝试序列化一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅听莫相离 2024-08-15 21:07:36

分离二进制流确实需要大量有关实现的知识。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文