Home
Options

LINQPad throws System.Argument exception in .Dump()

On dumping a relatively complex object, .Dump is throwing the below exception. Is this a known issue or is there any way around this? This is on version v4.51.03(AnyCPU)

System.ArgumentException: '', hexadecimal value 0xFFFF, is an invalid character.
at System.Xml.XmlEncodedRawTextWriter.InvalidXmlChar(Int32 ch, Char* pDst, Boolean entitize)
at System.Xml.XmlEncodedRawTextWriter.WriteElementTextBlock(Char* pSrc, Char* pSrcEnd)
at System.Xml.XmlEncodedRawTextWriter.WriteString(String text)
at System.Xml.XmlWellFormedWriter.WriteString(String text)
at System.Xml.Linq.ElementWriter.WriteElement(XElement e)
at System.Xml.Linq.XElement.WriteTo(XmlWriter writer)
at System.Xml.Linq.XNode.GetXmlString(SaveOptions o)
at LINQPad.ObjectGraph.Formatters.XhtmlFormatter.Visit(SimpleNode g)
at LINQPad.ObjectGraph.SimpleNode.Accept(IObjectGraphVisitor visitor)
at LINQPad.ObjectGraph.Formatters.XhtmlFormatter.b__68(MemberDescriptor header, IEnumerable`1 result)
at System.Linq.Enumerable.d__6a`4.MoveNext()
at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content)
at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content)
at LINQPad.ObjectGraph.Formatters.XhtmlFormatter.GetTableDataRow(IEnumerable`1 members, MemberDescriptor[] columnHeaders, Object rowInjection)
at LINQPad.ObjectGraph.Formatters.XhtmlFormatter.<>c__DisplayClass27.b__20(<>f__AnonymousType3c`2 <>h__TransparentIdentifier1d)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content)
at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content)
at LINQPad.ObjectGraph.Formatters.XhtmlFormatter.Visit(ListNode g)
at LINQPad.ObjectGraph.ListNode.Accept(IObjectGraphVisitor visitor)
at LINQPad.ObjectGraph.Formatters.XhtmlFormatter.Format(ObjectNode node, Boolean stripOuterElement)
at LINQPad.ObjectGraph.Formatters.XhtmlWriter.FormatObject(Object value, String heading, Nullable`1 maxDepth, TimeSpan& formattingTime)
at LINQPad.ObjectGraph.Formatters.OutputWriter.WriteObject(Object value, String heading, Nullable`1 maxDepth)
at LINQPad.ObjectGraph.Formatters.OutputWriter.WriteLineObject(Object value, String heading, Nullable`1 maxDepth)
at LINQPad.Extensions.Dump[T](T o, String description, Nullable`1 depth, Boolean toDataGrid)
at LINQPad.Extensions.Dump[T](T o, String description, Nullable`1 depth)
at LINQPad.Extensions.Dump[T](T o)
at UserQuery.RunUserAuthoredQuery() in c:\Users\tom\AppData\Local\Temp\LINQPad\_nsikgjgs\query_pkvvfh.cs:line 90

Comments

  • Options
    edited October 2017
    Easy to reproduce.
    Works: "\uFFFF".Dump();
    Fails: new { Foo = "\uFFFF" }.Dump();

    This could be resolved by setting CheckCharacters in XmlReaderSettings/XmlWriterSettings instead of calling XElement.ToString():
    var xml = new StringReader("<p>&#xFFFF;</p>");
    var reader = XmlReader.Create(xml, new XmlReaderSettings { CheckCharacters = false });
    var elm = XElement.Load(reader);
    reader.Close();

    var buf = new StringWriter();
    var writer = XmlWriter.Create(buf, new XmlWriterSettings { CheckCharacters = false, OmitXmlDeclaration = true });
    elm.WriteTo(writer);
    writer.Close();

    buf.ToString().Dump();
  • Options
    Thanks - will do for next build.
Sign In or Register to comment.