Search code examples
c#.netxmlxmlreader

XmlReader.create() return none after second time


I got a strange situation when I call a function and pass her a Stream object for the use of an creation XmlReader object.

First time this function works well, but if I call her another time and give her the same stream later on code, I got some exception that is an outcome of that XmlReader.create() return None instead of getting an allocation of an XmlReader object again, why is that?
What can I do?


Solution

  • Can be that you need to reset the position between reads if you are reading the same stream twice:

    streamInstance.Position = 0;