Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#892 .NET Null Reference in XSLT ResultDocumentHandler

Michael Kay
.NET API (34)
Michael Kay

When using IResultDocumentHandler with xsl:result-document you get a NullReferenceException if you return a TextWriterDestination as the result of the HandleResultDocument method.

The problem is caused by the fact that the code calls GetResult on the XmlDestination object twice, and with some kinds of XmlDestination, this returns a different object each time; when Close is called in the handler, the result object is then not recognized as one that has previously been returned by the Resolve() method.

A patch is in Subversion. This solves another (theoretical) problem at the same time: it is entirely possible for the HashCode of the result object to change as a result of changes to the content, so use of a Hashtable is not safe. The revised code therefore does a direct search in a list of result objects.


  • Michael Kay
    Michael Kay

    Fixed in