本文介绍了RuntimeType:HTTP://schemas.datacontract.org/2004/07/System'预计不会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了,所以我得到的DataContractSerializer与我的对象图的工作。看到我前面的问题了解更多信息。







不过,我的一个域, _UserPropertyDefinitions ,定义如下图所示。它定义了该用户可以在数据结构添加到自定义对象属性的列表。该字符串是一个独特的键来标识属性,Type是属性的类型始终是一颗灵长类动物的类型像BOOL,INT,弦乐等等等等。



每个对象都有一个对应的词典(字符串键,对象的值)集合来存储它为任何用户属性



[数据成员]
私人字典<字符串类型> _UserPropertyDefinitions;



我的对象图连载罚款时,该属性是空集,但有一次我一个自定义属性添加到这个系列我在尝试用DataContractSerializer的序列化时,以下情况例外。



If I remove the DataMember attribute for this field the I can serialize/deserialize with out getting an exception, but of course I loose the settings I've created in this field.

解决方案

I'm pretty sure that Type isn't going to serialize very well - and arguably it doesn't belong in a data-contract anyway, since (being implementation specific) it defeats one of the main aims of a data-contract...

However, I expect the best approach would be to swap that for a Dictionary<string,string>, using the Type's AssemblyQualifiedName or FullName.

这篇关于RuntimeType:HTTP://schemas.datacontract.org/2004/07/System'预计不会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:28