I am trying to read an xml with an XmlReader, but I receive an exception on something that I didn't expect.
ArgumentException: Specified type 'System.Guid' is not supported.
System.Xml.XmlReader.ValueAs (System.String text, System.Type type, IXmlNamespaceResolver resolver)
System.Xml.XmlReader.ReadElementContentAs (System.Type type, IXmlNamespaceResolver resolver)
The exception was thrown in the following line of code:
propInfo.Value = _cReader.ReadElementContentAs(propInfo.PropertyType, null);
Where propInfo
is a wrapper for a public property (getter-setter) that has to be serialized. In this line of code I try to read the value from xml and set it in the wrapper. I thought that a System.Guid
would be supported, because there is also a XmlConvert.ToGuid()
method.
What is a good way to serialize an xmlelement of a single type via this way? I cannot use XmlSerializer
for complex reasons with Mono.