This project is read-only.
1
Vote

Issue with XmlReader initialization

description

There is an issue with this code in Utility.GetXmlReader method:
                using (var stringReader = new StringReader(xml.Trim()))
                {
                    var reader = XmlReader.Create(stringReader, settings);
                    reader.MoveToContent();
                    return reader;
                }
The StringReader created here will be disposed at unpredictable time, prior to XmlReader completing its work. The fix is to remove the 'using' construct around the 'stringReader' variable. The XML Reader will own and dispose of the String Reader automatically.

comments