在不同的framework版本的.NET序列化的稳定性 [英] Stability of .NET serialization across different framework versions

查看:223
本文介绍了在不同的framework版本的.NET序列化的稳定性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个项目我工作的需要关闭之前,序列化的数据结构,并从何时再次启动该序列数据恢复的状态。

A project I'm working on requires serializing a data structure before shutting down and restores its state from this serialized data when it start up again.

去年,我们正在建造的.NET 1.1,并遇到了一个棘手的问题,即

Last year, we were building for .NET 1.1, and ran into a tricky issue where

  • 在我们的code运行在.NET 2.0
  • 在更新一些软件,莫名其妙定置1.1客户默认
  • 在我们的code运行在.NET 1.1,无法进行反序列化的存储状态

这个特殊的问题是决心通过限制特定的软件升级,不应该是一个问题,现在,我们正在针对.NET 2.0框架(所以我们不可能在1.1上运行)。

This particular issue was "resolved" by barring that particular software upgrade, and shouldn't be a problem now that we're targeting the .NET 2.0 framework (so we can't possibly run on 1.1).

什么是机会,这个序列可能再次之间,2.0和较新的框架出现不兼容的?如果我们使用< supportedVersion> 来解决我们的code至2.0.50727,什么是2.0.50727.1434和2.0.50727.nnnn之间变化的机会(有些未来的版本)?数据结构正在连载的阵列,地图,字符串,等等从标准类库。

What is the chance that this serialization could again change incompatibly between, 2.0 and newer frameworks? If we use <supportedVersion> to fix our code to 2.0.50727, what are the chances of changes between 2.0.50727.1434 and 2.0.50727.nnnn (some future release)? The data structures being serialized are arrays, maps, strings, et cetera from the standard class libraries.

此外,是保证一个框架2.0.40607甚至会后进一步.NET升级将始终安装?指针微软的文档的欢迎。

Additionally, is it guaranteed that a 2.0.50727 framework will be always installed even after further .NET upgrades? Pointers to Microsoft documentation welcome.

推荐答案

的机会比较小(但不为0!)会有框架版本之间的变化。我们的目的是,你应该能够使用二进制序列化和远程客户端和运行不同版本的框架服务器之间的通信。 .NET 1.x和2.0 之间的不兼容是一个错误了解其中补丁可用。

The chances are low (but not zero!) that there will be changes between framework versions. The intention would be that you should be able to use binary serialization and remoting to communicate between a client and a server running different framework versions. The incompatibility between .NET 1.x and 2.0 is a bug for which a patch is available.

不过二进制序列有其他的问题,为您的序列结构的版本尤其是穷人的支持。从你所描述的用例,XML序列化是显而易见的选择:DataContractSerializer的比XmlSerializer的更加灵活,如果你不介意在.NET 3.x的依赖

However binary serialization has other issues, especially poor support for versioning of the structure you're serializing. From the use case you've described, Xml serialization is the obvious choice: DataContractSerializer being more flexible than XmlSerializer if you don't mind the dependency on .NET 3.x.

您不能保证在.NET Framework 2.0将永远在未来版本的Windows安装。但我敢肯定,微软将努力工作,确保大多数.NET 2.0的应用程序将运行在.NET 4.x和更高版本不变。我没有这个任何引用。任何这样的承诺,在任何情况下才真正适用于Windows(Windows 7)中的下一个版本

You can't guarantee that the .NET framework 2.0 will always be installed on future versions of Windows. But I'm sure Microsoft will work hard to ensure that most .NET 2.0 apps will run unchanged on .NET 4.x and later versions. I don't have any references for this: any such commitment would in any case only really apply to the next version of Windows (Windows 7).

这篇关于在不同的framework版本的.NET序列化的稳定性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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