使用服务中的ObservableCollection的System.Runtime.Serialization.InvalidDataContractException [英] System.Runtime.Serialization.InvalidDataContractException using a ObservableCollection in a Service

查看:67
本文介绍了使用服务中的ObservableCollection的System.Runtime.Serialization.InvalidDataContractException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Error =" System.Runtime.Serialization.InvalidDataContractException:类型'System.Collections.ObjectModel.ObservableCollection`1 [T]'无法导出为架构类型,因为它是开放的泛型类型。如果所有通用参数类型都是实际类型,则只能导出泛型类型。"

合同=


< ServiceContract()> P

Error="System.Runtime.Serialization.InvalidDataContractException: Type 'System.Collections.ObjectModel.ObservableCollection`1[T]' cannot be exported as a schema type because it is an open generic type. You can only export a generic type if all its generic parameter types are actual types."

Contract=

<ServiceContract()>  P

ublic 接口 ITestServer
< OperationContract()> < ServiceKnownType(GetType(ObservableCollection(Of)))> _

ublic Interface ITestServer
<OperationContract()> <ServiceKnownType(GetType(ObservableCollection(Of )))> _

 

函数cGetSQLDataSources()As ObservableCollection(Of DarwinObjectModel.DarwinObjectModel.SQLDataSource)

另一个函数在接口返回数据集没有问题(如果我注释掉流氓函数)

结束

接口

Interface

 

推荐答案

这是一个自定义类吗? DarwinObjectModel.DarwinObjectModel.SQLDataSource类需要指定DataContract属性,并且所有暴露的属性都需要指定DataMember属性。

快乐编码!
Is this a custom class?  The class DarwinObjectModel.DarwinObjectModel.SQLDataSource needs to specify DataContract attribute and all properties exposed need to specify DataMember attribute.

Happy Coding!


这篇关于使用服务中的ObservableCollection的System.Runtime.Serialization.InvalidDataContractException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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