For some reason my exceptions arent being thrown anymore in Visual Studio. I get the error in JSON on the response, but Visual Studio in debug mode no longer throws an error and stops Visual Studio at that error when it happens.
I have looked into posts like this:
Visual Studio not stopping on an exception being thrown
But I just want to reset where I was before, not enable exceptions one by one.
To reset the exceptions settings, go to Debug>Exceptions and click "Reset All."
You can also drill down and control what happens for different types of exceptions.
update
You mentioned that you are missing the User-Unhandled column. In that case, you may need to set this:
Cntrl + Alt + E (Or Debug -> Exceptions)
Then select "Reset All", that will return the default exceptions on.
I hit a problem where it wasn't stopping on an exception and resetting the exception settings worked for me. To expand on Jay's answer above, in VS 2019 that option to reset is in a slightly different place (arguably a step backward compared to how it was before, it's clearer there).
Go to debug -> windows -> exception settings
The reset button is now this icon here:
Related
I'm using VS 2019, I'm wondering if there is a way to break when an exception is thrown, even if it is caught.
I can't manage to find out where the exception is really thrown since there are many exception handlers and the exception pop-up comes up when the stack is no longer indicating anything.
Thanks
You have to go into the exception settings of Visual studio (you can easily find it with the search bar)
And then you check the exception category that is needed (CLR for example)
Uncheck it after when it is no more needed (or use the restore default button)
I'm using Web Api and when an exception happens in my code (for example a bad cast), and the debugger is attached, the exception is not thrown in Visual Studio. I just get the 500 internal server error on the browser side with the exception details but it's a pain because I have to track down what line it's thrown on.
I don't believe this was always the case, and thought it must be one of my settings messed up but I have already tried to reset visual studio settings to no avail.
How can I get the debugger to break again on 500 internal server errors.. I don't want to enable first chance exceptions.
Tools -> Options -> Debugging -> General, Ensure that "Enable Just My Code" is checked.
In visual studio Debug->Exceptions for exceptions that you need or for all of them select checkbox in the Throw column. It's because by default Asp.Net runtime handles all exceptions. MSDN
I was reading Stack Overflow question How can I set Visual Studio to show a stack trace for first chance exceptions? regarding debugging first chance exceptions on Visual Studio 2010, and I am not able to find this option.
How can I enable Visual Studio 2010 to break exactly when a first chance exception happens?
You may want to check the Debug menu in Visual Studio 2010. In there you will find the Exception submenu, in where you can select which type of exception you want Visual Studio to stop.
Setting the debugger to break when an exception is thrown
The debugger can break execution at the point where an exception is
thrown, giving you a chance to examine the exception before a handler
is invoked.
In the Exception Settings window, expand the node for a category of
exceptions (for example, Common Language Runtime Exceptions, meaning
.NET exceptions), and select the check box for a specific exception
within that category (for example System.AccessViolationException).
You can also select an entire category of exceptions.
If you check a given exception, debugger execution will break wherever
the exception is thrown, regardless of whether it is handled or
unhandled. At this point the exception is called a first chance
exception.
See How to: Break When an Exception is Thrown for more info.
In Visual Studio to enable 1st chance exceptions we can open the exceptions window and check the throw CLR Exception chekbox.
On the debug menu select exceptions. (Ctrl + Alt + E)
There is a Common Language Runtime Exception Thown checkbox that we can check; then click OK.
The screen show below is from VS2012:
Hope this helps
As far as I remember, Visual Studio (both 2008 and 2010) used to have an option to break either on thrown exceptions or on unhandled exceptions. Now when I bring up the Exceptions dialog (Ctr+Alt+E), it just offers to break when an exception is thrown:
I've tried resizing to the columns in that dialog, but that did not help. Is this a bug, or am I missing something?
This seems to indicate it can occur if you don't have "Enable Just My Code (Managed Only)" enabled.
Edit: just tried it here (VS 2008) and I can verify that disabling that option will cause the User-Unhandled column to disappear. You can find the option here: Tools -> Options -> Debugging -> General
I have this as well when I've enabled source-server support in VS.NET.
When I have source-server support disabled, then the option to break on unhandled exceptions is still visible.
But, a thought: is it necessary to be able to specify that the IDE should break when an exception is unhandled ? As far as i know, this is just default behaviour, isn't it ? So, what's the use to be able to specify that option ?
I have a solution comprising of about 6 projects, and when I debug on one machine, any un-handled exceptions that occur cause the environment to break at the point that exception is thrown, allowing me to debug it.
However, on a different machine with the same solution (in the same version of VS), all I get when an exception is thrown is the "Visual Studio Just-In-Time debugging" window popping up, which tells me the name of the exception, and little else - it offers to open a new visual studio instance in order to debug it, but that doesn't work, because it is already being debugged by the IDE!
What is going on, and how can I get back to visual studio telling me where the exception happened?
Cheers
You might want to check Exceptions in the Debug menu (mapped by default to Ctrl+Alt+E) and verify that both machines have the same exceptions selected.
Probably on the second machine you have less exception types selected in that window. When one of the exceptions that are not selected is thrown:
the debugger does not handle it because it has been instructed not to
the exception gets passes to the OS
the OS launches the default system-wide debugger which is the "Visual Studio Just-In-Time debugging" launcher if you installed VS2005 on that machine.
Sounds like it can't find the debug info.
Try copying the PDB files to your output directory.
I've had this problem as well - two machines, identical exception settings, different behaviours. The solution for me was to set the Debugger Type in the project properties on the "bad" machine to Mixed, even though the application only contains managed code. On the "good" machine exceptions are caught in Visual Studio using the Managed Only setting.