G
George Ter-Saakov
I have 2 classes one is document and another is collection of documents.
When i am trying to use XmlSerializer to serialize class which has
clsDcoumentIds member variable i am getting an exception
"System.InvalidOperationException: The type clsDocumentId was not expected."
public class clsDocumentId
{
string _sDocumentId;
public clsDocumentId() {}
[XmlElement("DocumentId")]
public string DocumentId {
get {return _sDocumentId;}
set { _sDocumentId = value;}
}
}
public class clsDocumentIds
{
ArrayList _lstDocumentIds = new ArrayList();
[XmlArrayAttribute(ElementName="DocumentId")]
public ArrayList DocumentIds {
get {return _lstDocumentIds;}
set {_lstDocumentIds = value;}
}
}
What is the solution?
PS: Also if i follow a suggestion VS comipler gives to use
"Use the XmlInclude or SoapInclude attribute to specify types that are not
known statically."
I get incorrect XML
<DocumentIds>
<DocumentId>
<anyType xsi:type="clsDocumentId">
<DocumentId>aasds</DocumentId>
</anyType>
</DocumentId>
</DocumentIds>
Thanks.
George.
When i am trying to use XmlSerializer to serialize class which has
clsDcoumentIds member variable i am getting an exception
"System.InvalidOperationException: The type clsDocumentId was not expected."
public class clsDocumentId
{
string _sDocumentId;
public clsDocumentId() {}
[XmlElement("DocumentId")]
public string DocumentId {
get {return _sDocumentId;}
set { _sDocumentId = value;}
}
}
public class clsDocumentIds
{
ArrayList _lstDocumentIds = new ArrayList();
[XmlArrayAttribute(ElementName="DocumentId")]
public ArrayList DocumentIds {
get {return _lstDocumentIds;}
set {_lstDocumentIds = value;}
}
}
What is the solution?
PS: Also if i follow a suggestion VS comipler gives to use
"Use the XmlInclude or SoapInclude attribute to specify types that are not
known statically."
I get incorrect XML
<DocumentIds>
<DocumentId>
<anyType xsi:type="clsDocumentId">
<DocumentId>aasds</DocumentId>
</anyType>
</DocumentId>
</DocumentIds>
Thanks.
George.