【发布时间】:2011-02-14 00:04:12
【问题描述】:
我在 Windows Server 上有一个 WCF 服务,我正在尝试从 MonoDevelopment 中的 iPhone 应用程序调用该服务。 Web 服务客户端是使用 Silverlight 服务生成实用程序生成的,并复制到 MonoTouch 环境中的 iPhone 开发项目中。
所以服务非常简单。我有一个调用GetCustomers() 方法并返回List<Customer> 的方法。我可以在 MonoTouch iPhone 应用程序代码中成功创建客户端。该方法确实执行,如果我尝试对结果进行计数,它会告诉我有 91 条记录(Northwind 数据库/客户表)。因此,我确信该服务运行良好。
问题是当我尝试访问 Customer 对象的任何属性时,我收到以下错误:
CustomerName 属性确实有公共 getter 和 setter
但以下异常表明它没有。如果有人能告诉我我做错了什么,我需要一些帮助!
异步操作中的异常:System.Runtime.Serialization.InvalidDataContractException:类型“NorthwindService.Customer”上的 DataMember 属性“System.String CustomerName”必须同时具有 getter 和 setter。 在 /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System 中的 System.Runtime.Serialization.SharedContractMap.GetMembers(System.Type 类型,System.Xml.XmlQualifiedName qname,Boolean declared_only)[0x00116] .Runtime.Serialization/SerializationMap.cs:553 在 System.Runtime.Serialization.SharedContractMap.Initialize () [0x00053] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:516 在 System.Runtime.Serialization.KnownTypeCollection.RegisterContract(System.Type 类型)[0x0004f] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:766 在 System.Runtime.Serialization.KnownTypeCollection.TryRegister (System.Type 类型) [0x0002a] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:593 在 System.Runtime.Serialization.KnownTypeCollection.RegisterCollection(System.Type 类型)[0x0000f] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:666 在 System.Runtime.Serialization.KnownTypeCollection.TryRegister (System.Type 类型) [0x00062] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:605 在 System.Runtime.Serialization.KnownTypeCollection.InsertItem(Int32 索引,System.Type 类型)[0x00000] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection。 CS:389 在 System.Collections.ObjectModel.Collection`1[T].Add (.T item) [0x0000c] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Collections.ObjectModel/Collection.cs:72 在 /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ 中的 System.Runtime.Serialization.DataContractSerializer.ReadObject(System.Xml.XmlDictionaryReader 阅读器,布尔验证对象名称)[0x0000c] DataContractSerializer.cs:267 在 System.Runtime.Serialization.XmlObjectSerializer.ReadObject(System.Xml.XmlDictionaryReader 阅读器)[0x00000] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs :74 在 System.ServiceModel.Dispatcher.DataContractMessagesFormatter.MessageToParts (System.ServiceModel.Description.MessageDescription md, System.ServiceModel.Channels.Message 消息) [0x000b8] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/ System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:364 在 /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System 中的 System.ServiceModel.Dispatcher.BaseMessagesFormatter.DeserializeReply(System.ServiceModel.Channels.Message 消息,System.Object[] 参数)[0x00043]。 ServiceModel.Dispatcher/BaseMessagesFormatter.cs:175 在 System.ServiceModel.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] 参数) [0x0016a] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ ClientRuntimeChannel.cs:500 在 System.ServiceModel.ClientRuntimeChannel.DoProcess(System.Reflection.MethodBase 方法,System.String operationName,System.Object[] 参数)[0x00038] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System .ServiceModel/ClientRuntimeChannel.cs:443 在 System.ServiceModel.ClientRuntimeChannel.Process(System.Reflection.MethodBase 方法,System.String operationName,System.Object[] 参数)[0x00000] 在 /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System .ServiceModel/ClientRuntimeChannel.cs:425【问题讨论】: