Cannot locate source of "Object reference not set to an instance of an object."

G

Gummy

Hello,

I've been banging my head against the wall for a few days on this.

When I run a page, either in "View in Browser" or I actually build the
solution, I occasionally and very randomly get the following message:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.



When I set the Debugger to break during Exceptions, it breaks before any
code and just showed me some assembly-language looking stuff (I certainly
don't know about this).

I tried making a completely new solution, and bit-by-bit figure out where
the error is occurring. This started off OK, and I have a general idea where
it may be, but I am still having a problem pinpointing it.

Could anyone kindly give some suggestions on finding the problem?

Thanks so much.
 
G

Guest

Gummy,
what you are missing is a way to handle unhandled exceptions and do
something useful. Consider:

ASP.NET : GetLastError Handler:
// in global.asax:
protected void Application_Error(Object sender, EventArgs e)
{
ExceptionHandler.LogException exc = new ExceptionHandler.LogException();
Exception ex = Server.GetLastError().GetBaseException();
// pass ex to your logging or notification utility
}

Your loggin utiity could be as simple as a text file or the Event Log, I
leave that implementation up to you. Make sure you capture the StackTrace as
that is where the exact line of code where things "blew up" is identified.
Good luck!
Peter
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top