K
Kevin Burton
I have two properties that I am trying to serialize:
[XmlAttribute(AttributeName="last_updated")]
public DateTime LastUpdated
{
get
{
return lastUpdated;
}
set
{
lastUpdated = value;
}
}
[XmlAttribute(AttributeName="elapsed",
DataType="dateTime")]
public TimeSpan Elapsed
{
get
{
return timeSpan;
}
set
{
timeSpan = value;
}
}
The first, a DateTime seems to serialize just fine. The
second, a TimeSpan gives me the following exception:
There was an error reflecting property 'Elapsed'.
at
System.Xml.Serialization.XmlReflectionImporter.ImportStruct
LikeMapping(Str
uctModel model, String ns)
at
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMa
pping(TypeModel
model, String ns, ImportContext context, String dataType,
Boolean repeats)
-----------------------
Cannot serialize member 'Elapsed'. XmlAttribute/XmlText
cannot be used to encode
complex types.
at
System.Xml.Serialization.XmlReflectionImporter.ImportAccess
orMapping(Membe
rMapping accessor, FieldModel model, XmlAttributes a,
String ns, Type choiceIden
tifierType)
at
System.Xml.Serialization.XmlReflectionImporter.ImportFieldM
apping(StructMo
del parent, FieldModel model, XmlAttributes a, String ns)
at
System.Xml.Serialization.XmlReflectionImporter.ImportStruct
LikeMapping(Str
uctModel model, String ns)
-----------------------
I was under the impression that there was very little
different between DateTime and TimeSpan. Has anyone been
able to serialize and deserialize a TimeSpan structure?
Thank you.
Kevin
[XmlAttribute(AttributeName="last_updated")]
public DateTime LastUpdated
{
get
{
return lastUpdated;
}
set
{
lastUpdated = value;
}
}
[XmlAttribute(AttributeName="elapsed",
DataType="dateTime")]
public TimeSpan Elapsed
{
get
{
return timeSpan;
}
set
{
timeSpan = value;
}
}
The first, a DateTime seems to serialize just fine. The
second, a TimeSpan gives me the following exception:
There was an error reflecting property 'Elapsed'.
at
System.Xml.Serialization.XmlReflectionImporter.ImportStruct
LikeMapping(Str
uctModel model, String ns)
at
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMa
pping(TypeModel
model, String ns, ImportContext context, String dataType,
Boolean repeats)
-----------------------
Cannot serialize member 'Elapsed'. XmlAttribute/XmlText
cannot be used to encode
complex types.
at
System.Xml.Serialization.XmlReflectionImporter.ImportAccess
orMapping(Membe
rMapping accessor, FieldModel model, XmlAttributes a,
String ns, Type choiceIden
tifierType)
at
System.Xml.Serialization.XmlReflectionImporter.ImportFieldM
apping(StructMo
del parent, FieldModel model, XmlAttributes a, String ns)
at
System.Xml.Serialization.XmlReflectionImporter.ImportStruct
LikeMapping(Str
uctModel model, String ns)
-----------------------
I was under the impression that there was very little
different between DateTime and TimeSpan. Has anyone been
able to serialize and deserialize a TimeSpan structure?
Thank you.
Kevin