如何修复Visual Studio移植问题? [英] How to Fix Visual studio Porting issue??

查看:83
本文介绍了如何修复Visual Studio移植问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要注意的要点:

我的项目最初是在VS 2012中开发的 - >版本1.0并使用MVVM架构。

My Project was developed in VS 2012 initially -> version 1.0 and makes use of MVVM architecture.

我的项目的下一版本已从VS 2012升级到VS 2015 - >版本2.0。

Next version of my project was upgraded from VS 2012 to VS 2015 -> version 2.0.

我使用c#Binary Formatter [序列化/反序列化]来保存用户图表数据。

I used c# Binary Formatter [serialization/deserialization] to save user chart data.

问题:

我的软件保存/加载二进制格式的用户数据,类似于保存/打开项目。

My software saves/loads user data which is in binary format and is similar to save/open project.

我有一些用户保存的二进制文件,这些文件保存在版本中1.0软件。

I have some user saved binary files, these files were saved in Version 1.0 software.

当我尝试在2.0版软件中打开这些文件时,会抛出序列化异常。反序列化文件时会抛出异常。

When I try to open these files in version 2.0 software serialization exception is being thrown. Exception is thrown for Deserialization of file.

现在,

我将2.0版软件降级到VS 2012.我再次尝试打开这些文件,它成功打开了这些文件。

I downgraded version 2.0 software to VS 2012. Again I tried to open these files, it opened those files successfully.

我能够在降级版本2.0软件中打开1.0版文件,但我无法在VS 2012版本中打开以前保存的2.0版文件。

I was able to open version 1.0 files in downgraded version 2.0 software but I am unable to open previously saved version 2.0 files in VS 2012 build.

我的结论:

MS build与VS 2012和VS 2015之间内部链接的执行方式有所不同。这导致反序列化问题。

There is difference in MS build and how the linking is performed internally between VS 2012 and VS 2015. And this is causing the issue in deserialization.

我的问题:我需要支持在版本2.0软件中打开版本1.0文件而不影响2.0行为。

My question: I need to support open of Version 1.0 file in Version 2.0 software without affecting 2.0 behavior.

有没有办法解决这个问题??

Is there any way to solve this issue??

任何建议都有帮助

推荐答案

如果您正在使用运行时序列化(包括BinaryFormatter和SoapFormatter),问题是它将序列化程序集的版本嵌入到序列化文件中,然后它尝试反序列化到相同的版本。如果
在程序中只有一个新版本的程序集正在进行反序列化,那么它就会失败。

If you are using Runtime Serialization (which includes the BinaryFormatter and the SoapFormatter), the problem is that it embeds the version of the serialized assembly inside the serialized file, and then it tries to deserialize to the same version. If you only have a new version of the assembly in the program that is doing the deserialization, then it fails.

要解决这个问题,我倾向于避免运行时序列化。相反,我使用XmlSerializer或JSON序列化程序。这两种方法都只保存普通数据,没有版本化信息,因此可以毫不费力地处理任何版本的
软件。

To work around this issue, I tend to avoid Runtime Serialization. Instead, I use either the XmlSerializer or a JSON serializer. Either of this will only save the plain data, without versioning information, so it can be processed without trouble by any version of the software.


这篇关于如何修复Visual Studio移植问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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