8

I am debugging an asp.net application on iisexpress.exe, I have configured visual studio 2013 to break on user-handled exceptions through the exception settings window but it still does not break when an exception is thrown. When I pause execution I can see on the Intellitrace window that a lot of exceptions were thrown but visual studio didn't break.

Nadav Miller
  • 491
  • 2
  • 5
  • 15
  • Does setting breakpoints work? Can you see the `Output Window` has loaded the correct versions of your assemblies? – Patrick Hofman Jan 27 '14 at 09:37
  • There is no "user-handled" option. There's `Thrown` and `User-unhandled`, both of which must be selected for the behaviour you want. Did you select both those options? – Matthew Watson Jan 27 '14 at 09:44
  • @MatthewWatson - yes, that's what i meant. – Nadav Miller Jan 27 '14 at 10:37
  • @PatrickHofman - yes, it looks like it. the code runs and works, but visual studio is not pausing when and exception is thrown and caught. it is however, pausing on un handled exceptions. – Nadav Miller Jan 27 '14 at 10:41

2 Answers2

10

Ok, it seems it was because of the "Enable Just My Code" options was selected under

Options->Debugging->General

I don't know why but by default, it is checked. Any ideas? Should I leave it checked/unchecked?

naveen
  • 53,448
  • 46
  • 161
  • 251
Nadav Miller
  • 491
  • 2
  • 5
  • 15
8

@Navad, how the debugger works is that when you have "Just My Code" enabled, the debugger will only break on First Chance Exceptions (thrown, but handled) in user code. Where the debugger defines user code to be code that is compiled "Debug" and you have symbol files (.pdb's) for, or if the assembly is built by a project that is part of your solution. In general Just My Code is what you likely want, as if you disable it and turn on first chance exceptions you will break on any exceptions that occur even in framework code you don't control. Additionally when it is enabled, if you don't catch the Exception in user code the debugger will break and treat it as if it was unhandled. However if you disable Just My Code, you will break on the exception only if it is truly unhandled. For example some frameworks will catch exceptions so the debugger will only break if you switch it to thrown, because no exceptions in your code actually go unhandled, they are only "User Unhandled".