DotNet error message : on which statement ?

G

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
 
P

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).
 
M

Mr. Arnold

Gilbert said:
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.
 
G

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 said:
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 said:
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
 
M

Mr. Arnold

Gilbert said:
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.
 
P

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

Gilbert Tordeur said:
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 said:
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 said:
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
 
P

Phill W.

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.
 
G

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. said:
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.
 

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