RE: best debug / perfmon options to drilldown to find error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

The first thing I'd do is set the CLR to break into code whenever an
exception is thrown - that way you'll see exactly what's throwing the error
(unless it's from someone elses dll - but you should still be able to see
what's causing it in the call stack - I'll explain that in a mo.)

To set the CLR to "break on all errors" you need to go to the Exceptions
window (Debug->Exceptions or Ctrl-Alt-E) , click on the "Common Language
Runtime Exceptions" node in the exceptions list, and change the "When an
exception is thrown" option to "Break into the debugger"

Now run the code again...

When you get the exception, have a look at the call-stack window. (if it's
not visible you can get at it from Debug->Windows->Call Stack) At the top of
the list is the method the exception was raised from. That might provide
some insight into what's going wrong...

Failing that, if you could post the callstack here, someone here might be
able to help a bit more.

Cheers,
Mike

"chris yoker via DotNetMonster.com" wrote:

> hiya,
> I have winforms app that contains buttons.
> Any time that I click on any of the buttons, I get an error:
>
> <error>
> An unhandled exception of type 'System.NullReferenceException' occurred in
> system.windows.forms.dll
> Additional information: Object reference not set to an instance of an
> object.
> <\error>
>
> This error occurs BEFORE, the "Button_click" event fires.
>
> However, despite the fact that I set breakpoints at:
> 1) "btnClose_Click" event
> 2) "frmProduct_Closed" event
> 3) "frmProduct_Closing" event
>
> The app goes straight into a 'System.NullReferenceException' error.The
> breakpoints do not even reach the "btnClose_Click" event.I know for a fact
> that debugging works on this app.
> I am using vis studio 2003 + perfmon
> Also, I have added a ".net CLR memory" log to perfmon.
>
> Can anyone suggest which "debug" options will help me drilldown and find
> the error, eg callStack, threads?..ATM, I am only familiar with "watch" and
> "breakpoints"
>
> To be honest, I am dancing round in the dark.
>
> many thanks,
> yogi
>
> --
> Message posted via http://www.dotnetmonster.com
>
.



Relevant Pages

  • Re: System.ExecutionEngineException for certificate object creation
    ... The classic way to debug this would be to use a lower level debugger like ... see if they have any suggestions as a lot of the more hard core CLR guys ... > this specific call to object creation that is throwing the exception. ... > If I comment it out, no exception is thrown. ...
    (microsoft.public.dotnet.security)
  • Re: Having trouble changing a web service URL at runtime
    ... thrown, ... in the generated proxy remove ... > I'm playing with a simple smartphone app that communicates with a server ... > - An exception is thrown as the user doesn't have access to MyDevMachine ...
    (microsoft.public.dotnet.framework.compactframework)
  • RE: Problem trying to get a Bmp screenshot
    ... If we pass null to Bitmap's ctor, an exception will be thrown by ... CLR. ... Microsoft Community Support ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: .NET Runtime 2.0 Error - I need more details...
    ... We'll start coding all applications with event log exception ... default execption logging for the clr & non-asp.net exceptions. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework)
  • Native Exception in netcfagl1_0.dll
    ... my .NET CF app. ... The exception ... The exception code is 0xc0000005 and is thrown ... Selecting Debug ...
    (microsoft.public.dotnet.framework.compactframework)