如何在调试器中查看异常详细信息,而不将变量分配给异常? [英] How to see exception detail in debugger without assigning variable to exception?

查看:177
本文介绍了如何在调试器中查看异常详细信息,而不将变量分配给异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在visual studio调试器中看到异常细节,而不会将变量分配给异常。目前我必须这样写:

I want to see exception detail in visual studio debugger without assigning variable to exception. Currently I have to write something like this:

try 
{
    //some code
}
catch (SecurityException ex)
{
   //some code or ever no any code 
}

Visual studio抛出一个错误,指示ex变量永远不会使用,但是我需要这个变量才能在调试时看到异常详细信息。

Visual studio throws an error indicating that ex variable is never used, but i need this variable to see exception detail while debugging.

更新:我知道如何抑制VS错误'变量永远不会使用',问题是在没有此变量的情况下看到表中的异常。
$ @VladimirFrolov的异常变量或@MarcGravell的异常助手是一个答案。

UPDATE: I know how to suppress VS error 'variable is never used', problem is in seeing exception inside watch without this variable. $exception variable by @VladimirFrolov or exception helper by @MarcGravell is an answer.

推荐答案

您可以在本地列表中看到您的例外,或使用 $ exception 在观察列表中:

You can see your exception in Locals list or use $exception in Watch list:

try
{
    // some code
}
catch (SecurityException)
{ // place breakpoint at this line
}

这篇关于如何在调试器中查看异常详细信息,而不将变量分配给异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆