2010-02-04 47 views
0

我有以下的上課的時候類是序列化Web服務和System.InvalidOperationException在序列化

public class CustomFieldList : CustomField, IList 
    { 
     public CustomFieldList() 
     { 
       this.ControlType = Rflex.Framework.MetaData.ControlType.DDL; 
     } 
     public Type ReferentielType { get; set; } 
     public int? CustomCodeTableTypeID { get; set; } 
     public CustomCodeTableItem Value { get; set; } 
     public override object TheValue { get { return Value; } } 
    } 

它不能序列類型這可能是很正常的事情會拋出一個InvalidOperationException

堆棧(錯誤譯自法文所以這是不準確的):

System.InvalidOperationException:錯誤在處理XML。 ---> System.InvalidOperationException:無法識別Rflex.WebServices.Objects.Reference.CustomCodeTableItem類型。使用XmlInclude或SoapInclude屬性指定類型 àMicrosoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write32_Type(String n,String ns,Type o,Boolean isNullable,Boolean needType) àMicrosoft.Xml.Serialization。 GeneratedAssembly.XmlSerializationWriter1.Write33_CustomFieldList(字符串N,串NS,CustomFieldList O,布爾ISNULLABLE,布爾needType) àMicrosoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write74_JobDescription(字符串N,串NS,JobDescription O,布爾ISNULLABLE,布爾needType) àMicrosoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write77_Offer(String n,String ns,Offer o,Boolean isNullable,Boolean needType) àMicrosoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write96_Offer(Object o) àMicrosoft.Xml.Serialization.GeneratedAssembly.OfferSerializer.Serialize(對象objectToSerialize,XmlSerializationWriter作家) àSystem.Xml.Serialization.XmlSerializer.Serialize(的XmlWriter的XmlWriter,對象o,XmlSerializerNamespaces命名空間,字符串的encodingStyle,字符串ID)

我試着用屬性,但它不想工作。

非常感謝。

回答

0

你需要這樣的:

[XmlInclude(typeof(Rflex.WebServices.Objects.Reference.CustomCodeTableItem))] 

加入,實際上是從Web服務返回的類型。

相關問題