无法读取try catch短语的异常

Sar*_* S. 0 c# visual-studio-2008 visual-studio

我把我的代码放在try之间,像这样抓住

try
{
///
}
catch(Exception ex)
{
//here is where i set the break point
}
Run Code Online (Sandbox Code Playgroud)

但当它进入捕获时我无法在快速监视窗口中读取ex,因为它表示它在当前上下文中不存在.这是来自IDE本身吗?因为它发生在我工作的所有项目中.

Ian*_*las 6

您需要实际执行异常操作.我相信这与编译器\调试器的一些优化有关.基本上,编译器\调试器将看到异常不再被引用\使用,并且它将不可用.做类似以下的事情

try
{
///
}
catch(Exception ex)
{
   //here is where i set the break point
   Console.WriteLine(ex);
}
Run Code Online (Sandbox Code Playgroud)