什么是内置的BinaryFormatter基于净系列化的缺陷? [英] What are the deficiencies of the built-in BinaryFormatter based .Net serialization?
本文介绍了什么是内置的BinaryFormatter基于净系列化的缺陷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是内置的的BinaryFormatter 基于净系列化的不足之处? (性能,灵活性,限制)
What are the deficiencies of the built-in BinaryFormatter based .Net serialization? (Performance, flexibility, restrictions)
请伴随着一些code。如果可能的答案。
Please accompany your answer with some code if possible.
例如:
自定义对象被序列化必须装饰用[Serializable]属性或实现ISerializable接口。的
不太明显的例子:
匿名类型不能被序列化。的
推荐答案
如果你的意思是的BinaryFormatter
:
- 是基于领域,是十分版本不耐;更改私有实现细节和它打破(甚至只是改变它的自动实现的属性)
- 在不与其他平台 跨平台兼容性
- 在不向新的领域非常友好
- 是装配特定的(元数据被烧毁)
- 是MS / .NET具体的(和具体可能是.NET版本)
- 在不混淆安全
- 是不是特别快,或小输出
- 在没有光的框架运行(CF?/ Silverlight的)
- (通常是通过
事件
S)有拉的东西你没想到一去pressing习惯
- being based on fields, is very version intolerant; change private implementation details and it breaks (even just changing it to an automatically implemented property)
- isn't cross-compatible with other platforms
- isn't very friendly towards new fields
- is assembly specific (metadata is burnt in)
- is MS/.NET specific (and possibly .NET version specific)
- isn't obfuscation-safe
- isn't especially fast, or small output
- doesn't work on light frameworks (CF?/Silverlight)
- has a depressing habit of pulling in things you didn't expect (usually via
event
s)
我花了很多时间在这方面,包括编写(免费)实现谷歌的协议缓冲区序列化API为.NET; protobuf网
I've spent lots of time in this area, including writing a (free) implementation of Google's "protocol buffers" serialization API for .NET; protobuf-net
这是:
- 较小的输出和更快
- 与其他实现
- 扩展
- 合同为基础
- 混淆安全
- 装配独立
- 是一个开放的文档标准
- 适用于所有版本的.NET(警告:不是在微架构测试)
- 有挂钩插入
ISerializable的
(用于远程等)和WCF
- smaller output and faster
- cross-compatible with other implementations
- extensible
- contract-based
- obfuscation safe
- assembly independent
- is an open documented standard
- works on all versions of .NET (caveat: not tested on Micro Framework)
- has hooks to plug into
ISerializable
(for remoting etc) and WCF
这篇关于什么是内置的BinaryFormatter基于净系列化的缺陷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文