views:

200

answers:

3

We're getting an odd bug in a production server. We have a stack trace, but no line numbers, so I know the method where the bug is, but not the exact line. It's complaining of a "Object reference not set to an instance of an object." Something is null.

After looking at the code, the only two potential culprits that I can see are the two consecutive lines that read:

string currentPath = this.Request.CurrentExecutionFilePath;
string[] parts = currentPath.Split('/');

which would throw if Request was null, or if the CurrentExecutionFilePath of the Request was null. I'm not really clear on when (or even if) this can happen. Am I barking up the wrong tree here? (This code seems to be running during the Load portion of the page lifecycle).

+2  A: 

Oddly enough I have seen a null HttpRequest error (many many) times on a production server without ever being able to find out the cause.

I know that is of no use to you whatsoever but am just writing out of solidarity :)

One potential thing that I half remember was to do with IIS not mapping the root to /Default.aspx but again, this was all long ago so please don't pay too much attention to these potentialy unhelpful ramblings!!!

Justin Wignall
Actually, it is of use...I wasn't sure it could ever happen, so having independant verification that it can is useful. Thanks.
Beska
+2  A: 

Do you have PDB output enabled for your release build?

If you do you would only need to deploy the pdb to your production server to get line numbers in your stack trace.

(pdb and dlls have to match)

chris
I'll have to check the build super...not sure if he does, or if he'd have any restrictions on this. But the idea is sound.
Beska
A: 

The request and/or HttpContext can be null if you launch threads from your first one. (Asynchronous processing, etc.)

Jason Kealey