BUG: The XmlValidatingReader class does not close the stream when the XML document references a DTD that has errors
Symptoms
When you validate your XML document by using the XmlValidatingReader class with respect to an external document type definition (DTD), and the DTD has an error, the stream that is opened by XmlValidatingReader to load the DTD is not closed. Therefore, when you try to open the DTD with write permissions, you receive the following error message:
An unhandled exception of type ‘System.IO.IOException’ occurred in mscorlib.dll
Additional information: The process cannot access the file “DTDFileName” because it is being used by another process.
Resolution
When you use XmlValidatingReader to validate an XML document with respect to DTD, the .NET Framework internally opens a stream to read the DTD. When the error occurs while validating the XML document, the stream that is used to read the DTD is not closed, and you receive the error message that is listed in the “Symptoms” section.

Leave a Reply