使用服务中的ObservableCollection的System.Runtime.Serialization.InvalidDataContractException [英] System.Runtime.Serialization.InvalidDataContractException using a ObservableCollection in a Service
问题描述
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." <ServiceContract()> P ublic 接口 ITestServer ublic Interface ITestServer 函数cGetSQLDataSources()As ObservableCollection(Of DarwinObjectModel.DarwinObjectModel.SQLDataSource) 结束 接口 Interface
这篇关于使用服务中的ObservableCollection的System.Runtime.Serialization.InvalidDataContractException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
合同=
Contract=
< OperationContract()> < ServiceKnownType(GetType(ObservableCollection(Of)))> _
<OperationContract()> <ServiceKnownType(GetType(ObservableCollection(Of )))> _
另一个函数在接口返回数据集没有问题(如果我注释掉流氓函数)
推荐答案
这是一个自定义类吗? 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!