English 中文(简体)
数据循环兼容性问题
原标题:DataContractSerializer forward compatibility problem

I m using the DataContractSerializer for storing an object of my own class to save user settings. The UserSettings class uses some other objects of different data types. I add all of those types to the KnownTypes parameter of the DataContractSerializer wich works just fine. But i ve got issues with forward compatibility. If i introduce a new property in the UserSerrings class using a new data type it also works in the new version of my program. But the old version throws an exception saying that the XML file cannot be deserialized because the data type is not in the KnownTypes array. I simply want to ignore those types because they re not used in the old version anyway. How can i achieve this, so that the old version can read and write the xml file ignoring those unknown properties/types?

最佳回答

这正是IExtensibleDataObject(推广数据)为! 想法是,如果数据合同第1卷与延伸数据接口脱节,它将自动忽略数据合同今后修订的数据数据,包括未来未知类型,而没有任何问题。

d 我建议提供以下资源,以更多地了解这一特点,并学习如何为你的具体情况执行这一特征:

http://msdn.microsoft.com/en-us/library/ms731083.aspx” rel=“nofollow”> 具有前瞻性的数据合同

rel=“nofollow>> 数据合同文本

关于数据合同版本的进一步指导意见......

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签