这个c#例外意味着什么:“在分析结束之前遇到的流的结束”? [英] What does this c# exception mean: "end of stream encountered before the end of the analysis"?

查看:98
本文介绍了这个c#例外意味着什么:“在分析结束之前遇到的流的结束”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我序列化一个巨大的列表(二进制序列化)都正常工作但是当我尝试反序列化时,会引发一个异常,说:在分析结束之前遇到的流的结束如何克服这个问题?



请尽量清楚,先谢谢所有贡献者

I serialize a huge list(binary serialization) all works properly but when i try to deserialize, an exception is raised saying that: "the end of the stream encountered before the end of the analysis" How to overcomer this issue?

Please try to be clear, thanks in advance to all contributors

推荐答案

这意味着无论你有什么反序列化是否已损坏或类型/版本与序列化数据不同。



检查您调用泛型加载的方式方法:您是序列化派生类并反序列化基类,反之亦然?
It means that whatever you are deserializing is either corrupted or of a different type / version than the serialized data.

Check the way you call the generic load method: are you serializing a derived class and deserializing a base class, or vice versa?


- 您确定序列化是否成功完成?你有一个空的捕获,所以所有异常都被吞下。

- 尝试使用不同的格式化程序,这样你至少可以读取输出文件来检查它是否正常



如果您完全确定序列化工作正常,请关注反序列化:



- 尝试在加载时将FileStream的位置设置为0。

- 您确定类型规格是否正确,设备和连接器是非通用列表吗?
- Are you sure that serialization completes successfully? You have an empty catch, so all exceptions are swallowed.
- Try using a different formatter so you can at least read the output file to check if it's okay

If you're absolutely sure that serialization works well, focus on deserialization:

- Try setting the position of the FileStream to 0 when loading.
- Are you sure the type specifications are correct, equipments and connectors being NON-generic lists?


这篇关于这个c#例外意味着什么:“在分析结束之前遇到的流的结束”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆