views:

715

answers:

2

Usually, Visual Studio breaks if it encounters an unhandled exception and shows an exception assistant window.

But in some occasions, Visual Studio instead just stops the program that was running and does not break or show the exception helper.

The exception options (Ctrl+Alt+E) are configured correctly: "user-unhandled" is checked on all items, "thrown" is unchecked. In the debugging options, i have enabled the exception assistant.

Because it only happens on some occassions, i tried to figure out when visual studio enters its "malfunctioning exception assistant state".

EDIT:

It looks like the malfunctioning exception assistant ghost only shows up in winforms applications, and only after there has been some external action like calling a web service or opening a database connection.

END EDIT

It turns out the exception assistant works fine until an ADODB connection is opened:

var conn = new ADODB.Connection();
conn.Open("Provider=SQLOLEDB;Server=localhost;Database=db;UID=user;PWD=pw;", "", "", -1);
throw new InvalidOperationException();

After excecuting the conn.Open statement, the exception assistant will never kick in.

Does this sound familiar to anyone, and, more important: does anyone have a solution for the problem? As you can imagine, debugging an application becomes very hard if the application always just quits on exceptions.

+2  A: 

Hi there,

I'm not entirely sure what causes this behaviour - but I've just had exactly the same thing happen to me.

The short version of this answer:

Reinstall Visual studio 2008 sp1. If you've not got that installed then I guess you can repair your VS installation, or simply apply sp1 now and it should fix it.

The long version:

I had an exception in my code, and visual studio was not displaying the debugging assistant at the point the exception happened - instead I would get the Windows Error Reporting dialog box, and a prompt asking me whether I wanted to debug the process! If I told VS to break when all exceptions were thrown it would work (but that's no way to debug an app).

Curiously, on the same machine I've been able to debug a WCF service running inside IIS7.5 - so I couldn't understand it.

After numerous expletives and repeated attempts, I disabled Windows Error Reporting. Still, the dialog box comes up, and VS wouldn't break on the exception.

So I disabled the Windows Error Reporting Service (it's started on demand) - this time the app would simply exit without displaying the dialog box - but still VS would not break on the exception.

In the end, I figured that perhaps there was a configuration problem with VS - so I reapplied Visual Studio 2008 sp1 and now it's all working properly again.

Andras Zoltan
I have already tried re-installing vs2008, but that did not help. But after I re-installed, i still had my own settings. What did you do to erase the settings?
Jan Willem B
Today I discovered I had not yet installed SP1. I have installed it now, but still the application just exits at an exception instead of VS displaying the debugging assistant
Jan Willem B
sorry for the delay - really need to switch email notifications on!Does the behaviour stop if you check all .Net exceptions under the 'Thrown' column on the Debug-->Exceptions menu?If so, then there could be something screwy going on with an exception filter in there somewhere.You can reset all environment settings by opening Tools-->Options-->Import And Export Settings. the bottom option is to reset all settings. You should export your current configuration so you can selectively import things like fonts and colours, folder locations etc before doing this, though.
Andras Zoltan
It DOES help to check the thrown column. (I do have notifications on, but did not see your reply either). I will post my experiences with resetting the settings in a different comment for readability.
Jan Willem B
Resetting the settings makes no difference.
Jan Willem B
Hmmm... by this point I'd got my debugging working again. Must confess - I'm stumped by this one; sorry!
Andras Zoltan
I'm having this problem and resetting all settings didn't work for me. Here's hoping SP1 (re?)install will fix it...
Greg
A: 

I'm getting something similar (the same behaviour), but I think This Microsoft Help Page also describes my situation: "Unhandled exceptions in Windows Form events are not propagated up call stack"

Greg
We are gradually moving projects to VS2010, so the problem is not very urgent any more. But thanks anyway.
Jan Willem B