I run this sample application:
class Program
{
static void Main()
{
var reader = System.Xml.XmlReader.Create(@"C:\nonXml.txt");
while (reader.Read()) { }
System.Console.WriteLine("Ok");
System.Console.ReadKey();
}
}
nonXml.txt
is a one-line text file with non-xml content.
When I run the application without the debugger, reader.Read
throws an expected XmlException
and the application exits with error. When I run it with the debugger (F5 in Visual Studio), debugger signals the exception but after pressing F5 (Continue) the application unexpectedly continues normally and writes "Ok".
What's going on in the debug mode in this case?