Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to handel NULL referance

How to handel NULL referance

Scheduled Pinned Locked Moved ASP.NET
sysadmincsharpasp-netdatabasesql-server
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vnsraj
    wrote on last edited by
    #1

    Hi All I have a web application in asp.net 1.1 and sql server 2000, it was running alright previously, but for some weeks users are reporting that they are facing error. In the application whenever any error comes , user is being redirected to an error page and the actual error message comes to our(the programmers) email. The error message is very long but I'll mention the important part:- In the email :- System.NullReferenceException: Object reference not set to an instance of an object. at CBSolutions.ETH.Web.newlook.VSPage.LoadPageStateFromPersistenceMedium() at System.Web.UI.Page.LoadAllState() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) The code for function CBSolutions.ETH.Web.newlook.VSPage.LoadPageStateFromPersistenceMedium() is :- protected override object LoadPageStateFromPersistenceMedium() { if (ConfigurationSettings.AppSettings["ServerSideViewState"].ToUpper() == "TRUE") { string VSKey; VSKey = Request.Form["__VIEWSTATE_KEY"]; if (!(VSKey.StartsWith("VIEWSTATE_"))) { throw new Exception("Invalid VIEWSTATE Key: " + VSKey); } if (ConfigurationSettings.AppSettings["ViewStateStore"].ToUpper() == "CACHE") { return Cache[VSKey]; } else { DataTable VsDataTable; DataRow DbRow; VsDataTable = ((DataTable) Session["__VSDataTable"]); DbRow = VsDataTable.Rows.Find(VSKey); // if (DbRow!=null) // { // throw new Exception("VIEWStateKey not Found. Consider increasing the ViewStateTableSize parameter on Web.Config file."); // } return DbRow["VsData"]; } } else { return base.LoadPageStateFromPersistenceMedium(); } } Also in the Event Viewer application log, the following warning appears:- Event code: 3005 Event message: An unhandled exception has occurred. . . . . . Thread information: Thread ID: 6 Thread account name: NT AUTHORITY\NETWORK SERVICE Is impersonating: False Stack trace: at System.Web.HttpServerUtility.MapPath(String path) at ETH.Global.Session_End(Object sender, EventArgs e) Here ETH.Global.Session_End(Object sender, EventArgs e) is written in Global.asax which is as follows:- protected void Session_End(Object sender, EventArgs e) { //clean up temporary files string[] files = System.IO.Directory.GetFiles(Server.MapPath("Files/"),"WF-" + Session.SessionID + "*.*");

    B V 2 Replies Last reply
    0
    • V vnsraj

      Hi All I have a web application in asp.net 1.1 and sql server 2000, it was running alright previously, but for some weeks users are reporting that they are facing error. In the application whenever any error comes , user is being redirected to an error page and the actual error message comes to our(the programmers) email. The error message is very long but I'll mention the important part:- In the email :- System.NullReferenceException: Object reference not set to an instance of an object. at CBSolutions.ETH.Web.newlook.VSPage.LoadPageStateFromPersistenceMedium() at System.Web.UI.Page.LoadAllState() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) The code for function CBSolutions.ETH.Web.newlook.VSPage.LoadPageStateFromPersistenceMedium() is :- protected override object LoadPageStateFromPersistenceMedium() { if (ConfigurationSettings.AppSettings["ServerSideViewState"].ToUpper() == "TRUE") { string VSKey; VSKey = Request.Form["__VIEWSTATE_KEY"]; if (!(VSKey.StartsWith("VIEWSTATE_"))) { throw new Exception("Invalid VIEWSTATE Key: " + VSKey); } if (ConfigurationSettings.AppSettings["ViewStateStore"].ToUpper() == "CACHE") { return Cache[VSKey]; } else { DataTable VsDataTable; DataRow DbRow; VsDataTable = ((DataTable) Session["__VSDataTable"]); DbRow = VsDataTable.Rows.Find(VSKey); // if (DbRow!=null) // { // throw new Exception("VIEWStateKey not Found. Consider increasing the ViewStateTableSize parameter on Web.Config file."); // } return DbRow["VsData"]; } } else { return base.LoadPageStateFromPersistenceMedium(); } } Also in the Event Viewer application log, the following warning appears:- Event code: 3005 Event message: An unhandled exception has occurred. . . . . . Thread information: Thread ID: 6 Thread account name: NT AUTHORITY\NETWORK SERVICE Is impersonating: False Stack trace: at System.Web.HttpServerUtility.MapPath(String path) at ETH.Global.Session_End(Object sender, EventArgs e) Here ETH.Global.Session_End(Object sender, EventArgs e) is written in Global.asax which is as follows:- protected void Session_End(Object sender, EventArgs e) { //clean up temporary files string[] files = System.IO.Directory.GetFiles(Server.MapPath("Files/"),"WF-" + Session.SessionID + "*.*");

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      As the exception says,you must be eccesing some object that is not instantiated properly.So debug it and find which object is not getting created properly.

      Cheers!! Brij Check My Latest Article

      1 Reply Last reply
      0
      • V vnsraj

        Hi All I have a web application in asp.net 1.1 and sql server 2000, it was running alright previously, but for some weeks users are reporting that they are facing error. In the application whenever any error comes , user is being redirected to an error page and the actual error message comes to our(the programmers) email. The error message is very long but I'll mention the important part:- In the email :- System.NullReferenceException: Object reference not set to an instance of an object. at CBSolutions.ETH.Web.newlook.VSPage.LoadPageStateFromPersistenceMedium() at System.Web.UI.Page.LoadAllState() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) The code for function CBSolutions.ETH.Web.newlook.VSPage.LoadPageStateFromPersistenceMedium() is :- protected override object LoadPageStateFromPersistenceMedium() { if (ConfigurationSettings.AppSettings["ServerSideViewState"].ToUpper() == "TRUE") { string VSKey; VSKey = Request.Form["__VIEWSTATE_KEY"]; if (!(VSKey.StartsWith("VIEWSTATE_"))) { throw new Exception("Invalid VIEWSTATE Key: " + VSKey); } if (ConfigurationSettings.AppSettings["ViewStateStore"].ToUpper() == "CACHE") { return Cache[VSKey]; } else { DataTable VsDataTable; DataRow DbRow; VsDataTable = ((DataTable) Session["__VSDataTable"]); DbRow = VsDataTable.Rows.Find(VSKey); // if (DbRow!=null) // { // throw new Exception("VIEWStateKey not Found. Consider increasing the ViewStateTableSize parameter on Web.Config file."); // } return DbRow["VsData"]; } } else { return base.LoadPageStateFromPersistenceMedium(); } } Also in the Event Viewer application log, the following warning appears:- Event code: 3005 Event message: An unhandled exception has occurred. . . . . . Thread information: Thread ID: 6 Thread account name: NT AUTHORITY\NETWORK SERVICE Is impersonating: False Stack trace: at System.Web.HttpServerUtility.MapPath(String path) at ETH.Global.Session_End(Object sender, EventArgs e) Here ETH.Global.Session_End(Object sender, EventArgs e) is written in Global.asax which is as follows:- protected void Session_End(Object sender, EventArgs e) { //clean up temporary files string[] files = System.IO.Directory.GetFiles(Server.MapPath("Files/"),"WF-" + Session.SessionID + "*.*");

        V Offline
        V Offline
        Vimalsoft Pty Ltd
        wrote on last edited by
        #3

        Good Question but when you post in CP use the < pre > tags to format your code, i would like to help , but i loose interest because your code is not formated well

        int i=0;

        try to format it and we will answer

        Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.somee.com http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups