Jan Willem B
Jan Willem B

Reputation: 3806

Visual Studio does not break with exception assistant, but just stops the process

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.

Upvotes: 5

Views: 4203

Answers (4)

Arne Joris
Arne Joris

Reputation: 96

I ran into the exact circumstances as Jan Willem, with an ADODB.Connection.Open kicking me out of the program in visual studio instead of going into the debugging assistant. The problem was that the requested provider was using a 32-bit dll and I was compiling for 64 bit. Changing the project to 32-bit made the exception visible in visual studio.

Upvotes: 0

Code Jockey
Code Jockey

Reputation: 6721

I'm not sure if I understand how this could be happening, but I have a very similar problem. The helper does not seem to show up for me either. THE BIG DIFFERENCE is that it just goes back to my form, no crashing, no windows exception, doesn't finish the sub, like I called an exit sub at that point or something.

It's like this: I'm stepping through code and I reach a bit of bad code, I hit step into/over to execute the highlighted code, then all of a sudden my form is showing again, I can then interact with the form and continue as though nothing happened.... Especially annoying when I can't seem to see anything wrong in the code and I need the exception to tell me what went wrong (bad formatting string? incorrect types?)

Running VS 2010 Premium on Windows 7 x64... from what I know, I've got debugger settings as default (for a debugged windows forms application). Using VB.Net, no data connections (unless you count an XML file - but that doesn't seem to cause it...) nothing really special about the code, I think a simple stack overflow [...] would cause it to happen. Anyone have the same experience?

::Edit::
BTW, when it's not an obvious error, I put a try catch block around the spot that "has an exception" to catch the actual exception, then look at the caught exception in code - annoying, but it works!
::Edit Again::
Well, I seem to have found out how to get exception helper - I think someone here mentioned they had exhausted this option already, but it fixed my problem: [Debug -> Exceptions -> "Break when an exception is:" -> Common Language Runtime Exceptions: Thrown] should be checked - doesn't seem to make sense why it would keep running though... oh well
::End Edit::

Upvotes: 1

Greg
Greg

Reputation: 2179

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"

Upvotes: 0

Andras Zoltan
Andras Zoltan

Reputation: 42343

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.

Upvotes: 2

Related Questions