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 throws an error indicating that ex variable is never used, but i need this variable to see exception detail while debugging.
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.
When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.
With a solution open in Visual Studio, use Debug > Windows > Exception Settings to open the Exception Settings window. Provide handlers that respond to the most important exceptions. If you need to know how to add handlers for exceptions, see Fix bugs by writing better C# code.
When you're debugging and you get an exception, always, always, always click on the View Details link to open the View Details dialog. If the message in the dialog isn't expanded, expand it, then scan down to the Inner Exception entry.
Click Start and select Control Panel. Double-click Windows Firewall to open the Windows Firewall window. Click the Exceptions tab. Click to check mark the box for the program you want.
You can see your exception in Locals list or use $exception
in Watch list:
try { // some code } catch (SecurityException) { // place breakpoint at this line }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With