I have an XDocument that is throwing an invalid character (0x05) exception on ToString.
To help locate where I could be allowing a 0x05 char in where in the XDocument API can you let in a 0x05 character without some exception at that point, only to be thrown at ToString?
Specifically, as far as I recall, I only use the new Linq XML API, except that I do use some XmlSerialization through an extension method to return it to an XElement.
Just to show this was a worthy question before I found the simple answer: XElement:Parse does throw when the 0x05 character is included.
I’ve found that simply setting the
.Valueof anXElementdoes not check for invalid charaters 🙁The above doesn’t throw, until you then call
XDocument.ToStringon the containing Xml.