Consider the following code:
static void Main(string[] args)
{
using (MemoryStream memoryStream = new MemoryStream(Resources.SampleXMLFile)) // Breakpoint set here
{
using (XmlTextReader xmlTextReader = new XmlTextReader(memoryStream))
{
var z = XElement.Load(xmlTextReader);
}
}
Console.ReadLine();
}
I have a breakpoint set on the first using statement. Yet, the debugger does not hit it consistently.
My question:
Why does this happen? Am I neglecting a file handle?
Also:
Is this the best way to open an embedded resource XML file?