am using Visual Studio 2003, .Net Framework 1.1, C#. I get a SystemNullReferenceException when trying to do a hashtable.add(string,string) from a login page, and I do not understand why because all of the other data items from the Global.asax.cs are accessible in my pages. The key and value are not null (according to the watch window), so it is something else. This is likely something retarded, so I apologize in advance. It is my first attempt at a hash table. I am trying to store userid and sessionid for logging, statistics, troubleshooting (lol), etcetera.
Code Snippit from Global.asax.cs
public class Global : System.Web.HttpApplication
{
private System.ComponentModel.IContainer components = null;
public static string DatabaseConnectionString;
public static int NumberOfConnections;
public static int TotalConnectionsServiced;
public static DateTime DateStarted;
public static int FailedLoginAttempts;
public static int SuccessfulLoginAttempts;
public static string ErrorLogFile;
public static int TotalPagesServed;
public static Hashtable SessionTable;
public static Hashtable SessionTableSync;
public Global()
{
InitializeComponent();
DatabaseConnectionString=(string ) System.Configuration.ConfigurationSettings.AppSett ings["DBNameAndPath"];
NumberOfConnections=0;
TotalConnectionsServiced=0;
FailedLoginAttempts=0;
SuccessfulLoginAttempts=0;
ErrorLogFile=(string ) System.Configuration.ConfigurationSettings.AppSett ings["ErrorLogFile"];
TotalPagesServed=0;
DateStarted=System.DateTime.Now;
Hashtable SessionTable = new Hashtable();
Hashtable SessionTableSync = Hashtable.Synchronized(SessionTable);
Code Snippit from login.aspx----------------------------------------------------------------------------
Session.Add("UserID",sUserid);
Session.Add("FullName",sFullname);
Global.SuccessfulLoginAttempts++;
//System.NullReferenceException on the next line
Global.SessionTableSync.Add(sUserid,Session.Sessio nID); //tried with .ToString() also
I'm not trying to be dense, but I do have more of a procedural background than OO.
Thanks in advance,
Nick