Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8451767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:19:39+00:00 2026-06-10T11:19:39+00:00

I made a new class, and I’m getting a null reference exception, and I

  • 0

I made a new class, and I’m getting a null reference exception, and I cannot figure out why.

Object reference not set to an instance of an object.

    namespace TIMBaseClasses.ReturnerTracking
{
    [Serializable]
    public class Returner
    {
            private Guid _returnerID;
            private string _clientIP;

            public Guid returnerID {get { return _returnerID; } set { _returnerID = value; }}
            public string clientIP {get { return _clientIP; } set { _clientIP = value; }}


            /// <summary>Constructor that sets the default values as needed</summary>
            public Returner()
            {
                returnerID = Guid.Empty;
                clientIP = string.Empty;
            }

            public static Returner Instance
            {
                get
                {
                    var ret = (Returner)(HttpContext.Current.Session["Returner"] ?? new Returner());
                    HttpContext.Current.Session["Returner"] = ret;
                    return ret;
                }
            }


    }
}

The error happens towards the bottom, on the “var ret” line at the end when I call “new Returner()”.

The line that calls it that causes the error is as follows.

 Returner.Instance.returnerID = id;

EDIT

To address the concerns that the HTTPContext.Current is null, I did a watch and it is not null. However, a watch on “new Returner()” gives me this:

Instance = 'TIMBaseClasses.ReturnerTracking.Returner.Instance' threw an exception of type 'System.NullReferenceException'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:19:41+00:00Added an answer on June 10, 2026 at 11:19 am

    Its probably more likely that HTTPContext.Current or HTTPContext.Current.Session is null

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I create a new Exception different from the pre-made types? public class
I'm trying to set up a new class with a play() function. I'm not
I made a new class in Netbeans, and it has a little wrench icon
----Complete Rephrasing---- I was working on a new class where each instance was essentially
I am trying to make a method in a new class that I made...
I made a new action filter (attribute, similar to [Authorize]) which authorizes access to
I have made a new Excel 2010 Add-in project, with VS10. When I run
I made the following simulation: byte[] b = new byte[256]; for (int i =
I added a new file F1 and made changes to another file F2 but
I made a small winforms application to monitor a certain folder for new pdf

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.