Hi All,
In my [global.asa's], I will decrement a counter, like :
protected void Session_End(Object sender, EventArgs e)
{
ActiveSessionCount--; //CRASH !!
}
But, unexpectedly, it give me an "Global_asax]System.NullReferenceException:
Object reference not set to an instance of an object." at line [above] and
line [below].
I handle the increment/decrement of my session-counter with the code below:
protected static int ActiveSessionCount
{
get {
HttpContext.Current.Application.Lock(); //CRASH!!
int i = activeSessionCount; // private static declared.
HttpContext.Current.Application.UnLock();
return i;
}
set {
HttpContext.Current.Application.Lock();
activeSessionCount = value;
HttpContext.Current.Application.UnLock();
}
}
Why can the "HttpContext.Current.Application.Lock();" return a
NullReferenceException??? I am not able to understand this! Any help would
really be very welcomed!!!!
Best regards,
Manfred Braun
(Private)
Mannheim
Germany
mailto:_m*************@manfbraun.de
(Remove the anti-spam-underscore to mail me!) 3 3512
HttpContext.Current is a Request context. There is no
request during Session_End(), so HttpContext.Current is
null. -----Original Message----- Hi All,
In my [global.asa's], I will decrement a counter, like :
protected void Session_End(Object sender, EventArgs e) { ActiveSessionCount--; //CRASH !! }
But, unexpectedly, it give me an "Global_asax]
System.NullReferenceException: Object reference not set to an instance of an object."
at line [above] andline [below]. I handle the increment/decrement of my session-counter
with the code below: protected static int ActiveSessionCount {
get { HttpContext.Current.Application.Lock(); //CRASH!! int i = activeSessionCount; // private static
declared. HttpContext.Current.Application.UnLock(); return i; }
set { HttpContext.Current.Application.Lock(); activeSessionCount = value; HttpContext.Current.Application.UnLock(); } }
Why can the "HttpContext.Current.Application.Lock();"
return aNullReferenceException??? I am not able to understand
this! Any help wouldreally be very welcomed!!!!
Best regards, Manfred Braun
(Private) Mannheim Germany
mailto:_m*************@manfbraun.de (Remove the anti-spam-underscore to mail me!)
.
"Manfred Braun" <_m*************@manfbraun.de> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl... Hello Steve,
thanks so far, now I am more near to understand what I do ;-) Do you know, how I can access my application-instance to lock it??
For what you're doing, a lock of the Application instance is overkill. Just
use Interlocked.Decrement.
--
John Saunders
Internet Engineer jo***********@surfcontrol.com
Hi All,
thanks a lot for all the help!!!! I have it working now; Was just
disappointed how to lock the application itself from Session_End(), but
anyway, I have it working!!!
Thanks so far and
best regards,
Manfred
"Sherif ElMetainy" <el******@wayout.net> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl... Hello
you can use the c# lock keyword instead of Application.Lock ex.
private static readonly object sync = new object();
protected static int ActiveSessionCount { get { int i; lock(sync) { i = activeSessionCount; } return i; } set { { lock(sync) { activeSessionCount = value; } } } "Manfred Braun" <_m*************@manfbraun.de> wrote in message news:u#**************@TK2MSFTNGP12.phx.gbl... Hello Steve,
thanks so far, now I am more near to understand what I do ;-) Do you know, how I can access my application-instance to lock it??
Thanks so far and best regards, Manfred
"Steve Donnelly" <St************@countrywide.com> wrote in message news:02****************************@phx.gbl... HttpContext.Current is a Request context. There is no request during Session_End(), so HttpContext.Current is null.
>-----Original Message----- >Hi All, > > In my [global.asa's], I will decrement a counter, like : > > protected void Session_End(Object sender, EventArgs e) > { > ActiveSessionCount--; //CRASH !! >} > >But, unexpectedly, it give me an "Global_asax] System.NullReferenceException: > Object reference not set to an instance of an object." at line [above] and >line [below]. >I handle the increment/decrement of my session-counter with the code below: > > protected static int ActiveSessionCount > { > > get { > HttpContext.Current.Application.Lock(); //CRASH!! > int i = activeSessionCount; // private static declared. > HttpContext.Current.Application.UnLock(); > return i; > } > > set { > HttpContext.Current.Application.Lock(); > activeSessionCount = value; > HttpContext.Current.Application.UnLock(); > } > } > >Why can the "HttpContext.Current.Application.Lock();" return a >NullReferenceException??? I am not able to understand this! Any help would >really be very welcomed!!!! > >Best regards, >Manfred Braun > >(Private) >Mannheim >Germany > >mailto:_m*************@manfbraun.de >(Remove the anti-spam-underscore to mail me!) > >. >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nancy Drew |
last post by:
hi all
i'm trying to keep users from being able to login to a site twice at the
same time. everytime a user does a login, i stick their userID into an
application scoped array. if they try to...
|
by: Propin |
last post by:
Have a problem with below code in global.asa. Same problem as described in
this news group before, IWAM_machinename did not solve my problem.
Have created the following test code (file is never...
|
by: [Gauthier] |
last post by:
Hello,
I've a simple question:
On a server that run multiple asp.net HttpApplication, is there any way with
the asp.net framework to exchange data between different application?
I basically...
|
by: Hari Koduru |
last post by:
Hi All,
I am getting the following exception in an ASP.NET
application.
Exception Details: System.InvalidOperationException:
Application is restarting.
I have been to the following Support...
|
by: Fernando Arámburu |
last post by:
Hy everybody,
I´m working on an ASP.NET framework and and I need to extend
System.Web.HttpApplication. I mean, I need to put some intermediate class
between System.Web.HttpApplication and Global...
|
by: Tim Cartwright |
last post by:
I have a page that has the login control on it, nothing else. This page inherits from a master page, neither page has any code in it. This page works perfectly when running on the WebDev debug web...
|
by: miha.valencic |
last post by:
Hi!
A while ago, I noticed that there are usually two instances of
HttpApplication created within IIS (observed on WinXPPro). Why is that?
Especially, since Application_Start handler is called...
|
by: dpomt |
last post by:
I have overwritten Application_Error in my GlobalAsax to handle errors.
From time to time, I am getting exceptions I have never seen before (see
below).
What do this exceptions mean? Why are...
|
by: sqlguy |
last post by:
I am using a vendor package written in .net 2.0 C#. They say it works well,
and that I may have a configuration issue. The error I am getting is shown
below. Searching ms and google, it seems...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |