Home All Groups Group Topic Archive Search About

DotNet error message : on which statement ?

Author
12 Apr 2010 9:14 AM
Gilbert Tordeur
Hello.

An ASP.NET application reports the following error :

....
[NullReferenceException: Object reference not set to an instance of an
object.]
   RefFlu050.Page_Load(Object sender, EventArgs e) +1174
....

How can I identify which statement in my source code corresponds to
RefFlu050.Page_Load +1174 ?

Thanks in advance,
Gilbert

Author
12 Apr 2010 9:34 AM
Patrice
Hello,

How long is Page_load ? Some prefer to enable PDB files to get line numbers.
My personal experience is that if the app is well structured to it is
actually fairly easy to find out where it fails. Here you are trying to use
an object that is still Nothing (for example FindControl would be a posisble
cullprit).

--
Patrice

Show quoteHide quote
"Gilbert Tordeur" <gilbert.tord***@orange.fr> a écrit dans le message de
news:u8o9XCi2KHA.5212@TK2MSFTNGP04.phx.gbl...
> Hello.
>
> An ASP.NET application reports the following error :
>
> ...
> [NullReferenceException: Object reference not set to an instance of an
> object.]
>   RefFlu050.Page_Load(Object sender, EventArgs e) +1174
> ...
>
> How can I identify which statement in my source code corresponds to
> RefFlu050.Page_Load +1174 ?
>
> Thanks in advance,
> Gilbert
>
Author
12 Apr 2010 12:24 PM
Gilbert Tordeur
Hi Patrice.

I have been discouraged to enable PDB in production. I understand the nature
of the error (use of an object that has not yet been assigned).

My question is : can I use the information "+1174" somehow to identify which
statement it is related to ? This is a very rare error that we do not
understand and that we are not able to redo on demand.

Gilbert

"Patrice" <http://scribe-en.blogspot.com/> a écrit dans le message de news:
uK6ZjNi2KHA.5***@TK2MSFTNGP04.phx.gbl...
Show quoteHide quote
> Hello,
>
> How long is Page_load ? Some prefer to enable PDB files to get line
> numbers. My personal experience is that if the app is well structured to
> it is actually fairly easy to find out where it fails. Here you are trying
> to use an object that is still Nothing (for example FindControl would be a
> posisble cullprit).
>
> --
> Patrice
>
> "Gilbert Tordeur" <gilbert.tord***@orange.fr> a écrit dans le message de
> news:u8o9XCi2KHA.5212@TK2MSFTNGP04.phx.gbl...
>> Hello.
>>
>> An ASP.NET application reports the following error :
>>
>> ...
>> [NullReferenceException: Object reference not set to an instance of an
>> object.]
>>   RefFlu050.Page_Load(Object sender, EventArgs e) +1174
>> ...
>>
>> How can I identify which statement in my source code corresponds to
>> RefFlu050.Page_Load +1174 ?
>>
>> Thanks in advance,
>> Gilbert
>>
>
Author
12 Apr 2010 1:38 PM
Mr. Arnold
Gilbert Tordeur wrote:
> Hi Patrice.
>
> I have been discouraged to enable PDB in production. I understand the nature
> of the error (use of an object that has not yet been assigned).
>
> My question is : can I use the information "+1174" somehow to identify which
> statement it is related to ? This is a very rare error that we do not
> understand and that we are not able to redo on demand.
>

Well, you need a try/catch in the area where you might think the problem
is at and the try/catch should encompass any sub code that might be called.

catch ex
  ex.ToString()

It will give the module name and line number that aborted, along with
the full stack trace with inner exception message if it exist.
Author
12 Apr 2010 1:56 PM
Patrice
Are your PDBs still current ? If yes it should be the line number in your
source code but this is not always exact (If I remember JIT optimized code
could slightly offset the actual location resulting in a different line
retrieved from the PDB).

What do you have around 1174 ? If your Page_Load routine is huge you may
want to add a trace (possibly using HttpContext.Current.Items). That way
(and assuming you have a custom error handling routine that dumps this),
you'll be able to retrieve at least the area where it happens...

Later you may want to always structure your code in small chunks easier to
manage...

--
Patrice

Show quoteHide quote
"Gilbert Tordeur" <gilbert.tord***@orange.fr> a écrit dans le message de
news:usL%23rsj2KHA.6048@TK2MSFTNGP06.phx.gbl...
> Hi Patrice.
>
> I have been discouraged to enable PDB in production. I understand the
> nature of the error (use of an object that has not yet been assigned).
>
> My question is : can I use the information "+1174" somehow to identify
> which statement it is related to ? This is a very rare error that we do
> not understand and that we are not able to redo on demand.
>
> Gilbert
>
> "Patrice" <http://scribe-en.blogspot.com/> a écrit dans le message de
> news: uK6ZjNi2KHA.5***@TK2MSFTNGP04.phx.gbl...
>> Hello,
>>
>> How long is Page_load ? Some prefer to enable PDB files to get line
>> numbers. My personal experience is that if the app is well structured to
>> it is actually fairly easy to find out where it fails. Here you are
>> trying to use an object that is still Nothing (for example FindControl
>> would be a posisble cullprit).
>>
>> --
>> Patrice
>>
>> "Gilbert Tordeur" <gilbert.tord***@orange.fr> a écrit dans le message de
>> news:u8o9XCi2KHA.5212@TK2MSFTNGP04.phx.gbl...
>>> Hello.
>>>
>>> An ASP.NET application reports the following error :
>>>
>>> ...
>>> [NullReferenceException: Object reference not set to an instance of an
>>> object.]
>>>   RefFlu050.Page_Load(Object sender, EventArgs e) +1174
>>> ...
>>>
>>> How can I identify which statement in my source code corresponds to
>>> RefFlu050.Page_Load +1174 ?
>>>
>>> Thanks in advance,
>>> Gilbert
>>>
>>
>
>
Author
12 Apr 2010 12:05 PM
Mr. Arnold
Gilbert Tordeur wrote:
Show quoteHide quote
> Hello.
>
> An ASP.NET application reports the following error :
>
> ...
> [NullReferenceException: Object reference not set to an instance of an
> object.]
>    RefFlu050.Page_Load(Object sender, EventArgs e) +1174
> ...
>
> How can I identify which statement in my source code corresponds to
> RefFlu050.Page_Load +1174 ?
>
> Thanks in advance,
> Gilbert
>
>

You put a debug brake point on the first line in Page_Load, and you
start single stepping until it blows. Then you'll have a line number
where it blew and the line.

The other thing you do is turn on 'line numbering' in VS for code text
and the HTML text for the editor, as it could be blowing in the HTML
too, which will show you the line numbers.
Author
13 Apr 2010 2:43 PM
Phill W.
On 12/04/2010 10:14, Gilbert Tordeur wrote:

> An ASP.NET application reports the following error :
>
> ...
> [NullReferenceException: Object reference not set to an instance of an
> object.]
>     RefFlu050.Page_Load(Object sender, EventArgs e) +1174

> How can I identify which statement in my source code corresponds to
> RefFlu050.Page_Load +1174 ?

"+1174" denotes an offset into I.L. Code and not a line number.

You know which routine the exception occurred in (RefFlu050.Page_Load),
so you can use ildasm to "pull apart" that particular method.  The
offsets appear down the lefthand side, prefixed with "IL_":

     IL_001b:  ldloc.1
     IL_001c:  ldarg.1
     IL_001d:  ldarg.2
     IL_001e:  ldarg.3
     IL_001f:  callvirt   instance class
[System.Data]System.Data.DataSet [A.B.C.Processor]A.B.C.ID::E(string,
class [A.B.MiddleTier]A.B.C/ClientData,
class [A.B.Errors]A.B.IC&)
     IL_0024:  stind.ref
     IL_0025:  ldarg.3
     IL_0026:  ldind.ref

The "callvirt" entries are probably the most important ones, being calls
to others methods, hopefully ones that you wrote.

HTH,
    Phill  W.
Author
26 Apr 2010 1:40 PM
Gilbert Tordeur
Hi Phill.

(back from holiday)

ildasm, this is the tool I was missing (because of my ignorance).

Many thanks for your answer, I was able to identify the wrong statement.

Have a good day,
Gilbert


"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-k> a écrit dans le message
de news: hq1vub$nf***@south.jnrs.ja.net...
Show quoteHide quote
> On 12/04/2010 10:14, Gilbert Tordeur wrote:
>
>> An ASP.NET application reports the following error :
>>
>> ...
>> [NullReferenceException: Object reference not set to an instance of an
>> object.]
>>     RefFlu050.Page_Load(Object sender, EventArgs e) +1174
>
>> How can I identify which statement in my source code corresponds to
>> RefFlu050.Page_Load +1174 ?
>
> "+1174" denotes an offset into I.L. Code and not a line number.
>
> You know which routine the exception occurred in (RefFlu050.Page_Load), so
> you can use ildasm to "pull apart" that particular method.  The offsets
> appear down the lefthand side, prefixed with "IL_":
>
>     IL_001b:  ldloc.1
>     IL_001c:  ldarg.1
>     IL_001d:  ldarg.2
>     IL_001e:  ldarg.3
>     IL_001f:  callvirt   instance class [System.Data]System.Data.DataSet
> [A.B.C.Processor]A.B.C.ID::E(string,
> class [A.B.MiddleTier]A.B.C/ClientData,
> class [A.B.Errors]A.B.IC&)
>     IL_0024:  stind.ref
>     IL_0025:  ldarg.3
>     IL_0026:  ldind.ref
>
> The "callvirt" entries are probably the most important ones, being calls
> to others methods, hopefully ones that you wrote.
>
> HTH,
>    Phill  W.