这是我以前多次注意到的行为,我想知道背后的原因。如果您在(Visual Studio 2008)调试器下运行以下程序,则不管您继续调试的频率如何,调试器都将继续打破throw
语句。你必须停止调试才能走出去。我期望调试器会中断一次,然后过程终止,因为如果您在没有调试器的情况下运行该程序,就会发生这种情况。有没有人知道这种行为的一个很好的理由?为什么在调试时未处理的异常不会终止进程?
using System;
namespace ExceptionTest
{
static internal class Program
{
static internal void Main()
{
try
{
throw new Exception();
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
// The debuger will never go beyond
// the throw statement and terminate
// the process. Why?
throw;
}
}
}
}
问题是为什么我不能这样做并终止这个过程。 – 2009-10-08 11:02:50