Showing posts with label debugger. Show all posts
Showing posts with label debugger. Show all posts

What is a first chance exception anyway?

This kb article is the best explanation of what a first chance exception is I have ever read (http://support.microsoft.com/kb/105675):

“However, if the application is being debugged, the debugger sees all exceptions before the program does. This is the distinction between the first and second chance exception: the debugger gets the first chance to see the exception (hence the name). If the debugger allows the program execution to continue and does not handle the exception, the program will see the exception as usual. If the program does not handle the exception, the debugger gets a second chance to see the exception. In this latter case, the program normally would crash if the debugger were not present.”

How do I catch first chance exceptions?


In visual studio under the debug > exceptions menu and tick the boxes shown in red:

Edits were made which cannot be compiled. Execution cannot continue until the compile errors are fixed

I was getting a really annoying error today, visual studio (vs2008) kept claiming "Edits were made which cannot be compiled. Execution cannot continue until the compile errors are fixed". No didn't change anything though I swore after the 10th time. The code was compiling and running fine - I only got the error when I had a breakpoint set - without the breakpoint everything was hunky-doory.

Reading this connect bug http://connect.microsoft.com/VisualStudio/feedback/details/400456/edit-and-continue-preventing-execution-at-breakpoint-when-no-code-changes-were-made-in-vs2008 it looks like my issue was that I had silverlight and regular wpf/c# code in the same solution (different projects but some shared linked files with conditional #if SILVERLIGHT precompiler directives) and visual studio was somehow confusing the two.

Unloading the silverlight projects fixed the issue. The suggested work around on the connect site was to turn off edit and continue - that worked too.