我在Windows服务器上有一个WCF服务,我正试图从MonoDevelopment中的iPhone应用程序调用该服务。web服务客户端是使用Silverlight服务生成实用程序生成的,并复制到MonoTouch环境中的iPhone开发项目中。
所以服务很简单。我有一个方法,它调用GetCustomers()
方法并返回List<;客户>代码>。我可以在MonoTouch iPhone应用程序代码中成功创建客户端。该方法确实会执行,如果我尝试对结果进行计数,它会告诉有91条记录(Northwind数据库/Customers表)。所以我确信这项服务运行得很好。
问题是,当我尝试访问Customer对象的任何属性时,我会收到以下错误:
CustomerName属性没有公共getter和setter
但下面的例外情况表明它不是。如果有人能告诉我我做错了什么,我需要一些帮助!
Exception in async operation: System.Runtime.Serialization.InvalidDataContractException: DataMember property System.String CustomerName on type NorthwindService.Customer must have both getter and setter. at System.Runtime.Serialization.SharedContractMap.GetMembers (System.Type type, System.Xml.XmlQualifiedName qname, Boolean declared_only) [0x00116] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:553 at System.Runtime.Serialization.SharedContractMap.Initialize () [0x00053] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:516 at System.Runtime.Serialization.KnownTypeCollection.RegisterContract (System.Type type) [0x0004f] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:766 at System.Runtime.Serialization.KnownTypeCollection.TryRegister (System.Type type) [0x0002a] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:593 at System.Runtime.Serialization.KnownTypeCollection.RegisterCollection (System.Type type) [0x0000f] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:666 at System.Runtime.Serialization.KnownTypeCollection.TryRegister (System.Type type) [0x00062] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:605 at System.Runtime.Serialization.KnownTypeCollection.InsertItem (Int32 index, System.Type type) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:389 at System.Collections.ObjectModel.Collection`1[T].Add (.T item) [0x0000c] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Collections.ObjectModel/Collection.cs:72 at System.Runtime.Serialization.DataContractSerializer.ReadObject (System.Xml.XmlDictionaryReader reader, Boolean verifyObjectName) [0x0000c] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:267 at System.Runtime.Serialization.XmlObjectSerializer.ReadObject (System.Xml.XmlDictionaryReader reader) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs:74 at System.ServiceModel.Dispatcher.DataContractMessagesFormatter.MessageToParts (System.ServiceModel.Description.MessageDescription md, System.ServiceModel.Channels.Message message) [0x000b8] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:364 at System.ServiceModel.Dispatcher.BaseMessagesFormatter.DeserializeReply (System.ServiceModel.Channels.Message message, System.Object[] parameters) [0x00043] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:175 at System.ServiceModel.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x0016a] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:500 at System.ServiceModel.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00038] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:443 at System.ServiceModel.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:425