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'