Debugging

M

Mike W

When I run my project in Debug mode and I get an unhandled exception, I get
a window that says "An unhandled exception has occurred in your
application..." with Continue and Quit buttons. I would like for Visual
Studio to break on the line of code that caused the exception.

I have

<system.windows.forms jitDebugging="true" />

in my machine.config file and there is no application.config file.

Under the Debug -> Exception menu in Visual Studio, I have "If the exception
is not handled" set to "Break into the debugger" for all 4 exception types
listed.
 
C

Cor Ligthert

Mike,

You can set by right clicking a breakpoint or just the word Stop, what is a
little bit dangerous when you forget that.

I hope I understood you well and this helps?

Cor
 
M

Mike W

That's true, if I knew ahead of time that a line of code would be causing an
exception, then I could put a breakpoint on that line, but I would probably
change the code so that it doesn't cause an exception.

Anyway, I want Visual Studio to break on ANY line of code that causes an
exception. I have seen it do this before, so I know it is possible. Can
anyone help with this??
 
C

Cor Ligthert

Mike,

It is not impossible that the error apears in a part where is
<System.Diagnostics.DebuggerStepThrough()>

What is by instance in the designer part.

As well it can become because of an endless loop, than you don't know were
it is. This will happen in recursief methods by instance.

However just some guesses.

Cor
 
J

Jay B. Harlow [MVP - Outlook]

Mike,
Under the Debug -> Exception menu in Visual Studio, I have "If the
exception is not handled" set to "Break into the debugger" for all 4
exception types listed.
Did you try changing the "Debug - Exception - When the exception is thrown"
to "Break into the debugger" also?

As the dialog that you show (in your later post) is the one that Windows
Forms shows when you do not handle the Application.ThreadException event. In
other words Windows Forms is handling the exception for you, ergo it is not
a unhandled exception per se...

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top