I'm doing some Xml Serialization, and I'm getting a compile item error.
The code with the error is:
public class EPubBody
{
[XmlElement(ElementName = "Image", DataType = typeof(EPubImage))]
public object[] BodyItems;
}
The error is on the typeof(EPubImage)
part. The error is Cannot implicitly convert type 'System.Type' to 'string'
.
The class EPubImage
is in the same namspace, and looks like this:
public class EPubImage
{
[XmlAttribute("imagePath")]
public string ImagePath { get; set; }
}
I guess typeof(EPubImage)
is returning a System.Type
instead of an string
. Any pointers on how to ensure that the typeof statement will return a string, instead of a System.Type?
The MSDN Documentation for XmlElementAttribute clearly states that DataType
is string
, whereas the Type
property is of Type
.