473,385 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Static variables "lose" value

I've a very strange behaveour related to a website we built:
from times to times, something should happen on the server, and all static variables inside the web application, both defined inside aspx code-behind and in business logic (C# classes used by the aspx) lose their value.

I cannot reproduce this on our development server, so I cannot understand what the cause of all this is.

We are using asp.net 1.1 with IIS6 on win2003.

Nov 18 '05 #1
8 6747
This will happen if the app is recycled or re-booted.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:E5**********************************@microsof t.com...
I've a very strange behaveour related to a website we built:
from times to times, something should happen on the server, and all static variables inside the web application, both defined inside aspx code-behind
and in business logic (C# classes used by the aspx) lose their value.
I cannot reproduce this on our development server, so I cannot understand what the cause of all this is.
We are using asp.net 1.1 with IIS6 on win2003.

Nov 18 '05 #2
Your orginal post stated that static variables were losing their values.
Re-starting the app doesn't restore static variables' values: It
re-initializes them.

Static variables and objects are stored in the application heap. There are
only 2 ways to change their values:

1. Programmatically: Some code in your app changes the value
2. App restart: The heap is re-built from scratch, and the static variables
are re-initialized to their beginning state.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:45**********************************@microsof t.com...
I don't think this is the problem, because when the problem happens what I do to stop it and restore the original working is "recycling" the App Pool
(or making a small change to the web.config when I don't have access to the
server).
Simone

"Kevin Spencer" wrote:
This will happen if the app is recycled or re-booted.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:E5**********************************@microsof t.com...
I've a very strange behaveour related to a website we built:
from times to times, something should happen on the server, and all
static variables inside the web application, both defined inside aspx code-behind and in business logic (C# classes used by the aspx) lose their value.

I cannot reproduce this on our development server, so I cannot
understand what the cause of all this is.

We are using asp.net 1.1 with IIS6 on win2003.


Nov 18 '05 #3
OK... I'm not english mother tongue, so maybe there was a mis-understanding :-)

In my application static var are used to store values (objects) that are read during the startup from the DB.
When I said that "restore static variables' values" I meant that they are reinitialized

What I've is that when something happens, then all lines of code that access to any static variable throws a "System.NullReferenceException - Object reference not set to an instance of an object"

--
Simone Chiaretta
Milan, Italy
..Net Web Developer
"Kevin Spencer" wrote:
Your orginal post stated that static variables were losing their values.
Re-starting the app doesn't restore static variables' values: It
re-initializes them.

Static variables and objects are stored in the application heap. There are
only 2 ways to change their values:

1. Programmatically: Some code in your app changes the value
2. App restart: The heap is re-built from scratch, and the static variables
are re-initialized to their beginning state.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:45**********************************@microsof t.com...
I don't think this is the problem, because when the problem happens what I

do to stop it and restore the original working is "recycling" the App Pool
(or making a small change to the web.config when I don't have access to the
server).

Simone

"Kevin Spencer" wrote:
This will happen if the app is recycled or re-booted.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:E5**********************************@microsof t.com...
> I've a very strange behaveour related to a website we built:
> from times to times, something should happen on the server, and all static variables inside the web application, both defined inside aspx code-behind and in business logic (C# classes used by the aspx) lose their value.
>
> I cannot reproduce this on our development server, so I cannot understand what the cause of all this is.
>
> We are using asp.net 1.1 with IIS6 on win2003.
>


Nov 18 '05 #4
OK... I'm not english mother tongue, so maybe there was a mis-understanding :-)

In my application static var are used to store values (objects) that are read during the startup from the DB.
When I said that "restore static variables' values" I meant that they are reinitialized

What I've is that when something happens, then all lines of code that access to any static variable throws a "System.NullReferenceException - Object reference not set to an instance of an object"

--
Simone Chiaretta
Milan, Italy
..Net Web Developer
"Kevin Spencer" wrote:
Your orginal post stated that static variables were losing their values.
Re-starting the app doesn't restore static variables' values: It
re-initializes them.

Static variables and objects are stored in the application heap. There are
only 2 ways to change their values:

1. Programmatically: Some code in your app changes the value
2. App restart: The heap is re-built from scratch, and the static variables
are re-initialized to their beginning state.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:45**********************************@microsof t.com...
I don't think this is the problem, because when the problem happens what I

do to stop it and restore the original working is "recycling" the App Pool
(or making a small change to the web.config when I don't have access to the
server).

Simone

"Kevin Spencer" wrote:
This will happen if the app is recycled or re-booted.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:E5**********************************@microsof t.com...
> I've a very strange behaveour related to a website we built:
> from times to times, something should happen on the server, and all static variables inside the web application, both defined inside aspx code-behind and in business logic (C# classes used by the aspx) lose their value.
>
> I cannot reproduce this on our development server, so I cannot understand what the cause of all this is.
>
> We are using asp.net 1.1 with IIS6 on win2003.
>


Nov 18 '05 #5
In order to help you, I will need more exact information. You said that your
static variables "are used to store values (objects) that are read during
the startup from the DB." I need to know:

1. Where are they stored?
2. How are they fetched from the DB (what event handler loads them)?
3. What "something" happens to cause the error?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:F7**********************************@microsof t.com...
OK... I'm not english mother tongue, so maybe there was a mis-understanding :-)
In my application static var are used to store values (objects) that are read during the startup from the DB. When I said that "restore static variables' values" I meant that they are reinitialized
What I've is that when something happens, then all lines of code that access to any static variable throws a "System.NullReferenceException -
Object reference not set to an instance of an object"
--
Simone Chiaretta
Milan, Italy
.Net Web Developer
"Kevin Spencer" wrote:
Your orginal post stated that static variables were losing their values.
Re-starting the app doesn't restore static variables' values: It
re-initializes them.

Static variables and objects are stored in the application heap. There are only 2 ways to change their values:

1. Programmatically: Some code in your app changes the value
2. App restart: The heap is re-built from scratch, and the static variables are re-initialized to their beginning state.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:45**********************************@microsof t.com...
I don't think this is the problem, because when the problem happens what I
do to stop it and restore the original working is "recycling" the App Pool (or making a small change to the web.config when I don't have access to the server).

Simone

"Kevin Spencer" wrote:

> This will happen if the app is recycled or re-booted.
>
> --
> HTH,
> Kevin Spencer
> ..Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote
in > message news:E5**********************************@microsof t.com...
> > I've a very strange behaveour related to a website we built:
> > from times to times, something should happen on the server, and all static
> variables inside the web application, both defined inside aspx

code-behind
> and in business logic (C# classes used by the aspx) lose their

value. > >
> > I cannot reproduce this on our development server, so I cannot

understand
> what the cause of all this is.
> >
> > We are using asp.net 1.1 with IIS6 on win2003.
> >
>
>
>


Nov 18 '05 #6
BTW, patience is a virtue. If the message form doesn't submit immediately,
you might want to give it a little time before you re-submit your form - 15
times. ;-)

--
Ciao,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:90**********************************@microsof t.com...
OK... I'm not english mother tongue, so maybe there was a mis-understanding :-)
In my application static var are used to store values (objects) that are read during the startup from the DB. When I said that "restore static variables values" I meant that they are reinitialized
What I've is that when something happens, then all lines of code that access to any static variable throws a "System.NullReferenceException -
Object reference not set to an instance of an object"

--
Simone Chiaretta
Milan, Italy
.Net Web Developer
"Kevin Spencer" wrote:
Your orginal post stated that static variables were losing their values.
Re-starting the app doesn't restore static variables' values: It
re-initializes them.

Static variables and objects are stored in the application heap. There are only 2 ways to change their values:

1. Programmatically: Some code in your app changes the value
2. App restart: The heap is re-built from scratch, and the static variables are re-initialized to their beginning state.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:45**********************************@microsof t.com...
I don't think this is the problem, because when the problem happens what I
do to stop it and restore the original working is "recycling" the App Pool (or making a small change to the web.config when I don't have access to the server).

Simone

"Kevin Spencer" wrote:

> This will happen if the app is recycled or re-booted.
>
> --
> HTH,
> Kevin Spencer
> ..Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote
in > message news:E5**********************************@microsof t.com...
> > I've a very strange behaveour related to a website we built:
> > from times to times, something should happen on the server, and all static
> variables inside the web application, both defined inside aspx

code-behind
> and in business logic (C# classes used by the aspx) lose their

value. > >
> > I cannot reproduce this on our development server, so I cannot

understand
> what the cause of all this is.
> >
> > We are using asp.net 1.1 with IIS6 on win2003.
> >
>
>
>


Nov 18 '05 #7
The problem arise mainly in one object...
1 - it's a static variable inside the global.asax
2 - it's populated in the Application_onStart and nowhere else set

3 - The "something" is an unspecified event I cannot track back (a memory
leack? a bug inside .NET framework? whatever?) that cause the static variable
to become "null"

"Kevin Spencer" wrote:
In order to help you, I will need more exact information. You said that your
static variables "are used to store values (objects) that are read during
the startup from the DB." I need to know:

1. Where are they stored?
2. How are they fetched from the DB (what event handler loads them)?
3. What "something" happens to cause the error?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:F7**********************************@microsof t.com...
OK... I'm not english mother tongue, so maybe there was a

mis-understanding :-)

In my application static var are used to store values (objects) that are

read during the startup from the DB.
When I said that "restore static variables' values" I meant that they are

reinitialized

What I've is that when something happens, then all lines of code that

access to any static variable throws a "System.NullReferenceException -
Object reference not set to an instance of an object"

--
Simone Chiaretta
Milan, Italy
.Net Web Developer
"Kevin Spencer" wrote:
Your orginal post stated that static variables were losing their values.
Re-starting the app doesn't restore static variables' values: It
re-initializes them.

Static variables and objects are stored in the application heap. There are only 2 ways to change their values:

1. Programmatically: Some code in your app changes the value
2. App restart: The heap is re-built from scratch, and the static variables are re-initialized to their beginning state.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:45**********************************@microsof t.com...
> I don't think this is the problem, because when the problem happens what I do to stop it and restore the original working is "recycling" the App Pool (or making a small change to the web.config when I don't have access to the server).
>
> Simone
>
> "Kevin Spencer" wrote:
>
> > This will happen if the app is recycled or re-booted.
> >
> > --
> > HTH,
> > Kevin Spencer
> > ..Net Developer
> > Microsoft MVP
> > Big things are made up
> > of lots of little things.
> >
> > "Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in > > message news:E5**********************************@microsof t.com...
> > > I've a very strange behaveour related to a website we built:
> > > from times to times, something should happen on the server, and all static
> > variables inside the web application, both defined inside aspx
code-behind
> > and in business logic (C# classes used by the aspx) lose their value. > > >
> > > I cannot reproduce this on our development server, so I cannot
understand
> > what the cause of all this is.
> > >
> > > We are using asp.net 1.1 with IIS6 on win2003.
> > >
> >
> >
> >


Nov 18 '05 #8
Hi Simone,
1 - it's a static variable inside the global.asax
When you say "it's a static variable inside the global.asax" what exactly do
you mean? global.asax is a file that is compiled into a class. Is it a field
in the class? Is it a property? What exactly?

How is it populated? What kind of data is in it?

A variable doesn't just become null all by itself. Something has to change
it. Something has to set its value, and something has to make it null. It
would be really good if you could track down the event that is causing this
to happen, at least narrow the time down. Perhaps posting the code that
creates the variable would help also.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:50**********************************@microsof t.com... The problem arise mainly in one object...
1 - it's a static variable inside the global.asax
2 - it's populated in the Application_onStart and nowhere else set

3 - The "something" is an unspecified event I cannot track back (a memory
leack? a bug inside .NET framework? whatever?) that cause the static variable to become "null"

"Kevin Spencer" wrote:
In order to help you, I will need more exact information. You said that your static variables "are used to store values (objects) that are read during the startup from the DB." I need to know:

1. Where are they stored?
2. How are they fetched from the DB (what event handler loads them)?
3. What "something" happens to cause the error?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote in
message news:F7**********************************@microsof t.com...
OK... I'm not english mother tongue, so maybe there was a

mis-understanding :-)

In my application static var are used to store values (objects) that are
read during the startup from the DB.
When I said that "restore static variables' values" I meant that they
are reinitialized

What I've is that when something happens, then all lines of code that

access to any static variable throws a "System.NullReferenceException -
Object reference not set to an instance of an object"

--
Simone Chiaretta
Milan, Italy
.Net Web Developer
"Kevin Spencer" wrote:

> Your orginal post stated that static variables were losing their
values. > Re-starting the app doesn't restore static variables' values: It
> re-initializes them.
>
> Static variables and objects are stored in the application heap. There are
> only 2 ways to change their values:
>
> 1. Programmatically: Some code in your app changes the value
> 2. App restart: The heap is re-built from scratch, and the static

variables
> are re-initialized to their beginning state.
>
> --
> HTH,
> Kevin Spencer
> ..Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Simone Chiaretta" <Si*************@discussions.microsoft.com> wrote
in > message news:45**********************************@microsof t.com...
> > I don't think this is the problem, because when the problem happens what I
> do to stop it and restore the original working is "recycling" the
App Pool
> (or making a small change to the web.config when I don't have access
to the
> server).
> >
> > Simone
> >
> > "Kevin Spencer" wrote:
> >
> > > This will happen if the app is recycled or re-booted.
> > >
> > > --
> > > HTH,
> > > Kevin Spencer
> > > ..Net Developer
> > > Microsoft MVP
> > > Big things are made up
> > > of lots of little things.
> > >
> > > "Simone Chiaretta" <Si*************@discussions.microsoft.com>
wrote in
> > > message
news:E5**********************************@microsof t.com... > > > > I've a very strange behaveour related to a website we built:
> > > > from times to times, something should happen on the server,

and all
> static
> > > variables inside the web application, both defined inside aspx
> code-behind
> > > and in business logic (C# classes used by the aspx) lose their

value.
> > > >
> > > > I cannot reproduce this on our development server, so I cannot
> understand
> > > what the cause of all this is.
> > > >
> > > > We are using asp.net 1.1 with IIS6 on win2003.
> > > >
> > >
> > >
> > >
>
>
>


Nov 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Martin Robins | last post by:
I am trying to parse a string that is similar in form to an OLEDB connection string using regular expressions; in principle it is working, but certain character combinations in the string being...
2
by: Paul Brady | last post by:
I have non-computer skilled users entering data into a form. There are certain ranges of values which, if they enter them, make no sense in the application, but I can't test them until they try to...
35
by: David Cleaver | last post by:
Hello all, I was wondering if there were some sort of limitations on the "if" statement? I'm writing a program which needs to check a bunch of conditions all at the same time (basically). And...
2
by: Nathan Sokalski | last post by:
I have a form, and when the form does a PostBack (I have several areas on the form where the form changes if the user selects a different RadioButton), the Password field is cleared, even though I...
5
by: | last post by:
Hoping someone can help with a simple but puzzling problem. I have some code that I want to build as a class method. The code works fine when I embed it in Page_Load. But when I try to generalize...
9
by: Schraalhans Keukenmeester | last post by:
I am stomped with the following problem: I have a script start.php and a second script proceed.php Relevant (and working) sections of the code: start.php <?PHP start_session();
3
by: Yannick Turgeon | last post by:
Hello all, I'm using A97 and I'd like to keep about 30 informations concerning the logged in user, in order to prevent hundreds of DB access per user to get these informations (mainly rights +...
2
by: eholz1 | last post by:
Hello Group, does this make sense?? I have some java code that responds to keypress events (the arrow keys) <script language="javascript"> <!-- function keypressed(e) {
4
by: FullBandwidth | last post by:
I have been perusing various blogs and MSDN pages discussing the use of event properties and the EventHandlerList class. I don't believe there's anything special about the EventHandlerList class in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.