Re: NullReferenceException Message Feature Request

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Stu Smith (stuarts_at_remove.digita.com)
Date: 02/19/04


Date: Thu, 19 Feb 2004 09:30:22 -0000

Please tell me you have exceptions set to 'break' in the debugger.... if you
do, it's usually absolutely obvious what the null reference should have
been.

"Bryan Livingston" <anonymous@discussions.microsoft.com> wrote in message
news:6FDA50BD-7BF4-43C6-AD92-6DE18207002C@microsoft.com...
> I'm guessing that NullReferenceExceptions are by far the most common
exceptions thrown in .net.
>
> Why not add the type of the reference to the message? Have it say
something like:
> Object reference of type 'string' not set to an instance of an object.
>
> This would really help when trying to figure out where the null reference
is happening.
>
> I've just spent the last two days finding a null reference that happens
very intermittently. Having the type would have saved me many hours.
>
> In addition to just the type, you might be able to use reflection to give
a property name or variable name.
>
> Bryan Livingston
> Alphora.com



Relevant Pages

  • Re: NullReferenceException Message Feature Request
    ... Please tell me you have exceptions set to 'break' in the debugger.... ... it's usually absolutely obvious what the null reference should have ... > Object reference of type 'string' not set to an instance of an object. ... > I've just spent the last two days finding a null reference that happens ...
    (microsoft.public.dotnet.framework)
  • Re: Cobol data protection? Get a dog...
    ... "Parameters specified in the USING phrase of a method Procedure Division ... some of you who are most knowledgable about the standards process. ... dereference a reference (back to the invokers WS or worse back up through the ... I am aware that you can pass an object reference to a method, ...
    (comp.lang.cobol)
  • RE: reference to handle / handle to reference
    ... As far as I know, there's no conversion between an object reference and an Int32, unless you pin objects using GCHandles and get their associated IntPtrs. ...
    (microsoft.public.dotnet.general)
  • Re: Q: closing forms
    ... The only real difference between passing by reference and by value takes ... passing the object reference by reference ... If a Is Nothing Then MsgBox("After call using ByRef, ... Private Sub MyProcByReference ...
    (microsoft.public.dotnet.languages.vb)
  • [JavaIDL] Releasing CORBA object references in Java ?
    ... I was thinking that reference counting was the job of GC. ... But here in Java, the introduction of _releaseand _duplicate() is ... Returns a duplicate of this CORBA object reference. ...
    (comp.lang.java.corba)