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

Discussion in 'ASP .Net' started by Gummy, Jan 3, 2006.

  1. Gummy

    Gummy Guest

    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.
    Gummy, Jan 3, 2006
    #1
    1. Advertising

  2. RE: Cannot locate source of "Object reference not set to an instance o

    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

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "Gummy" wrote:

    > 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.
    >
    >
    >
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jan 3, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Parthiv Joshi
    Replies:
    2
    Views:
    670
    Kalyan
    Jul 2, 2004
  2. Suresh Kojhani
    Replies:
    1
    Views:
    2,362
    Anushi
    Jul 29, 2004
  3. Chris Fink
    Replies:
    2
    Views:
    4,063
    David Waz...
    Jul 3, 2003
  4. yysiow
    Replies:
    1
    Views:
    418
    Kevin Spencer
    Jul 12, 2003
  5. Replies:
    1
    Views:
    466
    Mark Rae [MVP]
    Sep 20, 2007
Loading...

Share This Page