0

Yesterday I was getting a NullReferenceException in my asp .net 2.0 web app. I couldn't figure out what was going wrong and at the end of my work day I decided to give up for the day, get some rest and come back to the problem and actually trace through my code and find where it broke.. Today (next day) I launch the web app and the problem is gone.

I know that it was pointing to a Page_Load in my code for the initial page (Default.aspx).

I guess I'm just kinda wondering how that happens? I know that when I started getting the exception I was really stumped because there were no code changes made or published to the server so that was the first thing that grabbed my attention and made me think that there was a problem with the server-client connection.

Anyways, no biggie if there isn't an answer out there, just kinda seemed silly. Sorry that I can't provide more details but I can't trace down the problem now. If it occurs again I'll be sure to trace the exception down in the code to exactly which line breaks it.

1 Answer 1

0

Maybe the reason why the exception was happening was because a correct value has been placed into an object? That error just doesn't go away by itself. NullReferenceException is common if you don't test for things like:

if (myObj != null)
  //ok to assign
else
  //not so ok handle it

So maybe from the time that you went and got rest and came back the following day a valid value was placed where this exception was occurring. But this exception can be thrown from anywhere, are you tapping into some sort of database?

Are you reading column data that should not be nullable?

Are you trying to access .ToString() on a null object, etc etc. Hundreds of reasons.....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.