I generated a hierarchy of classes from a xsd set of files. Say the class, that contains instances of other classes is Place and the place has Address, Categories, Tags and so on.
When trying to instantiate a new Tags object in a for loop, I get
ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array
It happens on this line, when in the loop:
tags currTags = new tags();
If I move that line out of the loop block, I get the same exception when I try to assign the filled with data object to the instance of the Place object:
currPlace.tags = currTags;
This is the definition of the class Tags:
[System.CodeDom.Compiler.GeneratedCodeAttribute("PrjName", "1.0.0.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://placeregistry.places.someaddress.com/xxx/v1")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://placeregistry.places.someaddress.com/xxx/v1", IsNullable=false)]
public partial class tags {
private tag[] tagField;
private string[] textField;
private System.Xml.XmlAttribute[] anyAttrField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("tag")]
public tag[] tag {
get {
return this.tagField;
}
set {
this.tagField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTextAttribute()]
public string[] Text {
get {
return this.textField;
}
set {
this.textField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAnyAttributeAttribute()]
public System.Xml.XmlAttribute[] AnyAttr {
get {
return this.anyAttrField;
}
set {
this.anyAttrField = value;
}
}
}
I just can't get it what happens and where do I go wrong in order to produce this error. Any ideas and suggestions are welcome!