In my global.asax Application_start method I set an application variable, then I set a timer object that calls a routine that check for the application variable but I always get an error when checking the application variable.
Code follows-
--- Global.asax ---
Sub Application_Start(ByVal sender AsObject, ByVal e AsEventArgs)
' Code that runs on application startupDim a = NewgeneralWebServiceHttpContext.Current.Application("usersOnline") = a.newOnlineUsersTable
a.setTimer()
EndSub
--- generalWebService ---
PublicSub setTimer()
Dim t AsNewTimer(30000)
AddHandler t.Elapsed, NewElapsedEventHandler(AddressOf checkOnlineUsersTable)
t.Enabled = TrueEndSub
PrivateSub checkOnlineUsersTable()
IfNotHttpContext.Current.Application("usersOnline") IsNothingThenDim t AsNewDataTable
t = HttpContext.Current.Application("usersOnline")
If t.Rows.Count > 0 ThenForEach r AsDataRowIn t.Rows
Dim ts AsNewTimeSpan(Now.Ticks - r("lastseen"))
If ts.Minutes > 2 Then
t.Rows.Remove(r)
EndIfNextEndIfEndIfEndSub
shtrudel
Member
461 Points
540 Posts
Global.asax application variables
Apr 29, 2012 01:07 PM|LINK
Hi there,
In my global.asax Application_start method I set an application variable, then I set a timer object that calls a routine that check for the application variable but I always get an error when checking the application variable.
Code follows-
--- Global.asax ---
--- generalWebService ---
I am getting the error on the red line.
Any idea why ?
Shoaib.Rashi...
Member
130 Points
41 Posts
Re: Global.asax application variables
Apr 29, 2012 01:18 PM|LINK
Please post error message
Shoaib.Rashi...
Member
130 Points
41 Posts
Re: Global.asax application variables
Apr 29, 2012 01:19 PM|LINK
Please post error message
shtrudel
Member
461 Points
540 Posts
Re: Global.asax application variables
Apr 29, 2012 01:25 PM|LINK
Error message follows:
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.