07-01-04 01:49 AM
I added a default constructor.
(Here is my class...)
[Serializable]
public class POClass {
[Property(typeof(PropertySchemas.IDs))]
public string ID;
public string Item;
public POClass() { }
}
Still...
a compile error "a class must have a default constructor to be serialized by
mlSerializer" reported.
I think...
Although there is no default constructor specified in class definition...
default constructor is provided implicitly when there is no any other
constructors.
so...
"a class must have a default constructor to be serialized by XmlSerializer"
means...a class should not be like this...
public class POClass {
[Property(typeof(PropertySchemas.IDs))]
public string ID;
public string Item;
public POClass(string s) { ID = s; }
}
So...
I solved the xml-serializable problem
by adding an attribute that control XML serialization....
[Serializable]
public class POClass
{
[Property(typeof(PropertySchemas.IDs))]
[XmlRootAttribute("PO")]
public string ID;
public string Item;
}
I feel...
this is not the right way to solve the compile error.
Plz...
comment me more...
[ Post a follow-up to this message ]
|