Search code examples
c#visual-studio-2008idisposablebreakpointsembedded-resource

Why doesn't the debugger hit this breakpoint consistently? Am I neglecting a file handle?


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?


Solution

  • Thanks to all who viewed this question.

    Here is how I fixed this problem:

    Closed and reopened Visual Studio.

    As an aside, I had a total of three Visual Studio instances open at the time.

    Shame on me for failing to consider that my machine might have had insufficient resources to execute the code.