Debugging Woes

C

ChrisM

I have written an application in C#, using VS.NET
When debugging the program, break-points etc. work find, but if I hit any
unhandled exceptions, I just get an Error box, and no chance to jump back to
the faulty code. The error box talks about invoking Just-In-Time debugging,
and I think I've done what it says:

Set 'Generate Debugging Information' in 'Project Properties' to TRUE

Added
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
to my app.config

But I still only get the Error Dialog, not the JIT debugger.

I'm sure that this used to work, but no more... Please can anyone suggest
what I might be missing or doing wrong.

Thanks,

ChrisM
 
L

Louis Marascio

Chris,

Go to Debug->Exceptions, and you should see a new dialog appear called
"Exceptions". Cliuck "Common Language Runtime Exceptions" and make
sure the bullet boxes on the bottom are set appropriately. For
unhandled exceptions, you should have "Break into the debugger"
selected.

Louis
 
C

ChrisM

Wow, that was a quick answer!
Sadly though, it didn't help. In that Dialog "Common Language Runtime
Exceptions" (which is the only item on my machine) has the following
settings:
'When the exception is thrown' - Continue
'If the exception is not handled' - Break Into The Debugger

Everything below that (including System.NulReferenceException which is the
one being thrown) is set to 'Use Parent Setting' for both.
This is the way it was already set, but still no JIT debugging.

Sorry! Any more suggestions?

ChrisM.
 
L

Louis Marascio

Chris,

Are you running the application from within VS.NET. I.e., VS.NET is
attached to the application while it is executing in Debug Mode? If
so, I think you may want to remove the line: <system.windows.forms
jitDebugging="true" /> from your config.

Either way, even if you get an error that asks you whether you want to
use the JIT debugger or a VS.NET debugger, you /should/ be able to see
where the exception occured.

Louis
 
C

ChrisM

Is it possible that my JIT debugger is not running, and hence not being able
to catch the exception?
How could I check that that is the case.
Cheers,

ChrisM
 
L

Louis Marascio

You are running a debug build, right?

Louis

ChrisM said:
Is it possible that my JIT debugger is not running, and hence not being able
to catch the exception?
How could I check that that is the case.
Cheers,

ChrisM
 
C

ChrisM

Yeesss... I think so.
If I got into Build->Configuration Manager

It says Active Configuration : Debug

Is that what you meant? Anything else I should check?

However, it is possible (tho I'm not sure) that this problem started when I
added a 'Release' Configuration. I'm quite sure I'm not using that at the
moment tho.

I have also just created a new Configuration (Debug2) which a created using
the 'Default Settings' still get the same problem :-(

In response to your earlier post, CLR debugger? Hmm, that makes me think
that since I am running my program inside of VS.NET, I shouldn't event be
bothering with the JIT debugger anyway. Is that correct? If so why doesn't
the CLR debugger pick up the fact that an exception has occured? it picks up
the break points OK?

Going home now, but thanks for your help so far. If you're around tomorrow
p'raps you could make some further suggestions?

Thanks a lot.

ChrisM
 
L

Louis Marascio

See if this has any effect. Go to Debug->Exceptions, and change "When
the Exception is Thrown" to "Break into the Debugger".
 
C

ChrisM

Yea, that has an effect.
It now breaks to the Debugger if an error occurs, but it does it even if the
error is handled (Does exactly what it say on the tin!)
So it seems that if I grab the exception as soon as it happens, the debugger
can handle it, but as soon as the exception goes into the CLRs Exception
Handling stuff, the debugger looses track of it, and it gets thrown in the
usual way...

ChrisM
 
C

ChrisM

One Last point, I have found that even if I am 'single stepping' through the
code, if an error is thrown, I get lobbed back to my Application and the
normal (ie non-debugger) exception message.

ChrisM
 
L

Louis Marascio

Chris,

I'm afraid I'm a bit perplexed here. Is it possible you have a global
exception handler installed in the AppDomain? There is an event in
there that you can subscribe to that will cause unhandled exceptions
to be handled.
 
C

ChrisM

I don't think so, as far as I know I have a standard install of VS.NET
I haven't knowingly subscribed to any events concerning exceptions.

Thanks for you suggestions anyway. Maybe I'll have to un/re-install VS....

Regards,

ChrisM
 

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