Object reference not set to an instance of an object.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • livmacca
    New Member
    • Mar 2008
    • 4

    Object reference not set to an instance of an object.

    Hi,

    I am new to VB .Net programming and is trying to create a webpage. I encountered the following error and is totally clueless on how to make it work:

    =============== ===ERROR======= =============== ============
    Object reference not set to an instance of an object.


    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.NullRefe renceException: 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.

    Stack Trace:


    [NullReferenceEx ception: Object reference not set to an instance of an object.]
    ICAPS_admin.Web Form1.Page_Load (Object sender, EventArgs e)
    System.Web.UI.C ontrol.OnLoad(E ventArgs e)
    System.Web.UI.C ontrol.LoadRecu rsive()
    System.Web.UI.P age.ProcessRequ estMain()

    =============== =============== =============== ============

    My webpage that I am trying to load is a very simple one which consist of only 3 dropdown list and 2 textbox. Below is my VB code:


    =============== ===Code =============== =============== =====
    [code=vbnet]
    Public Class WebForm1
    Inherits System.Web.UI.P age

    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()

    End Sub
    Protected WithEvents LabelSearchGemS ecNo As System.Web.UI.W ebControls.Labe l
    Protected WithEvents txtBoxGemSecNo As System.Web.UI.W ebControls.Text Box
    Protected WithEvents LabelSearchUser ID As System.Web.UI.W ebControls.Labe l
    Protected WithEvents txtBoxUserID As System.Web.UI.W ebControls.Text Box
    Protected WithEvents LabelStatus As System.Web.UI.W ebControls.Labe l
    Protected WithEvents LabelCAtype As System.Web.UI.W ebControls.Labe l
    Protected WithEvents LabelIndicator As System.Web.UI.W ebControls.Labe l
    Protected WithEvents ddlStatus As System.Web.UI.W ebControls.Drop DownList
    Protected WithEvents ddlCAtype As System.Web.UI.W ebControls.Drop DownList
    Protected WithEvents ddlIndicator As System.Web.UI.W ebControls.Drop DownList

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceho lderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Init
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    InitializeCompo nent()
    End Sub

    #End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
    'Put user code to initialize the page here
    End Sub


    Private Sub ddlCAtype_Selec tedIndexChanged (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles ddlCAtype.Selec tedIndexChanged

    End Sub
    End Class
    [/code]

    =============== =============== =============== ============

    Can anyone advise on this pls?

    Thanks and regards,

    livmacca
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    #2
    Put a breakpoint on the Page_Load event and run your web application. When the breakpoint is reached hit F11 to step through the application. What is the exact line of code executed when this error occurs?

    I'm failing to see anything wrong with the code you provided - so if you've provided everything in your project, then I'm thinking that it's an environment problem. But I'd rather not tell you that your Visual Studio needs reinstalling - lord knows it takes long enough.

    Comment

    • nev
      Contributor
      • Oct 2007
      • 251

      #3
      Check to see if anything being referenced is null or has valid data type.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        This is a VS2003 web application right? (In VS2005 you don't see the designer code like that)
        Did you leave out any code? it looks like your page_load event is empty, but that's where it says the error is comming from?

        Comment

        • livmacca
          New Member
          • Mar 2008
          • 4

          #5
          Originally posted by balabaster
          Put a breakpoint on the Page_Load event and run your web application. When the breakpoint is reached hit F11 to step through the application. What is the exact line of code executed when this error occurs?

          I'm failing to see anything wrong with the code you provided - so if you've provided everything in your project, then I'm thinking that it's an environment problem. But I'd rather not tell you that your Visual Studio needs reinstalling - lord knows it takes long enough.


          Hi,

          I guess it is the environment issue as it went away after i reinstalled VS 2003. Thanks for your reply! :)

          Comment

          Working...