开发者

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))
        {
            va开发者_StackOverflowr 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜