// This code was copied from XmlDictionaryReader.ReadElementContentAsDateTime which is an internal method public static DateTime ReadElementContentAsDateTime(this XmlDictionaryReader reader) { bool isEmptyElement = reader.IsStartElement() && reader.IsEmptyElement; DateTime value; if (isEmptyElement) { reader.Read(); try { value = DateTime.Parse(string.Empty, NumberFormatInfo.InvariantInfo); } catch (ArgumentException exception) { throw new XmlException(string.Format(SRServiceModel.XmlInvalidConversion, string.Empty, "DateTime"), exception); } catch (FormatException exception) { throw new XmlException(string.Format(SRServiceModel.XmlInvalidConversion, string.Empty, "DateTime"), exception); } } else { reader.ReadStartElement(); value = reader.ReadContentAsDateTimeOffset().DateTime; reader.ReadEndElement(); } return(value); }