【发布时间】:2009-07-21 13:45:47
【问题描述】:
我有这些课程:
public abstract class CustomField
{
public String Id { get; set; }
public String Name { get; set; }
public String Description { get; set; }
public FieldType Type { get; set; }
public enum FieldType
{
String = 0,
Integer = 1,
Boolean = 2,
List = 3
}
}
public class StringCustomField:CustomField
{
public String Value { get; set; }
public Int32 MinLenght { get; set; }
public Int32 MaxLenght { get; set; }
public StringCustomField()
{
this.Type = FieldType.String;
}
}
public class CustomGroup
{
public String Id { get; set; }
public String Name { get; set; }
public String Description { get; set; }
public List<CustomField> FieldList = new List<CustomField>();
}
当我尝试通过我的网络服务传输 CustomGroup 时,我收到此错误:
远程服务器返回错误:NotFound
当 C# 尝试通过我的 CustomField 传输我的 StringField 时,序列化失败。
我做错了什么?
Marc Gravel 告诉我这样做,我理解解决方案,但有些事情是错误的,没有效果,出现同样的错误!! ,救命!!
[XmlInclude(typeof(StringCustomField))]
[XmlInclude(typeof(IntegerCustomField))]
[XmlInclude(typeof(BooleanCustomField))]
[XmlInclude(typeof(ListCustomField))]
public abstract class CustomField
{
public String Id { get; set; }
public String Name { get; set; }
public String Description { get; set; }
public FieldType Type { get; set; }
public enum FieldType
{
String = 0,
Integer = 1,
Boolean = 2,
List = 3
}
}
【问题讨论】:
-
旁注:它是长度,而不是长度。但是,我的印象是,当您使用子类时,反序列化会成为问题。不幸的是,我不记得我是如何解决它的。查看 XmlArrayItemAttribute (msdn.microsoft.com/en-us/library/…)
-
投反对票是由于问题表述不佳/不专业,编辑已经解决了这个问题:)
标签: c# web-services serialization