Re: Static variables "lose" value
From: Kevin Spencer (kspencer_at_takempis.com)
Date: 08/04/04
- Next message: John Sivilla: "RE: Why cant I download a file with ASP.NET [WriteFile]"
- Previous message: John Sivilla: "RE: Problem sending date to SQL date time field"
- In reply to: Simone Chiaretta: "Re: Static variables "lose" value"
- Next in thread: Simone Chiaretta: "Re: Static variables "lose" value"
- Reply: Simone Chiaretta: "Re: Static variables "lose" value"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 4 Aug 2004 13:34:11 -0400
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" <SimoneChiaretta@discussions.microsoft.com> wrote in message news:F7D9AC77-1796-4707-8E6C-9A2F8F43ED42@microsoft.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" <SimoneChiaretta@discussions.microsoft.com> wrote in > > message news:4544B8F9-85F3-4644-B8B3-BA3F5E63E78B@microsoft.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" <SimoneChiaretta@discussions.microsoft.com> wrote in > > > > message news:E507B885-18F1-4B3F-A7A9-B0C4252CE035@microsoft.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. > > > > > > > > > > > > > > > > > > > > > > >
- Next message: John Sivilla: "RE: Why cant I download a file with ASP.NET [WriteFile]"
- Previous message: John Sivilla: "RE: Problem sending date to SQL date time field"
- In reply to: Simone Chiaretta: "Re: Static variables "lose" value"
- Next in thread: Simone Chiaretta: "Re: Static variables "lose" value"
- Reply: Simone Chiaretta: "Re: Static variables "lose" value"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|