Public Shared Variables are lost their values

M

Murat Fidan

Hi
i used Public Shared variables in my global.asax in vb.net 2003 and i wrote
code in Application_Start to fill variables.
i works but after some times ( 5 days ,2 days it is not same ) variables are
losing their values and they my site is not works :( .

How can i fix it ?

Thanks,
Murat
 
C

Cowboy \(Gregory A. Beamer\)

Create the global variables in a Singleton:

Public Class MySingleton

Private Shared MySingleton single

Private Sub New()
'Call routines that fill the global vars here
End Sub

Public Function GetSingleton() As MySingleton

If (single is Nothing) then
single = new MySingleton
End If

Return single

End Function

End Class

Using this pattern, any loss of info should reset the Singleton to Nothing.
If you wnt, you can also add bits that reconstitute if certain values are
empty. I do not think that is generally necessary, but there might be some
instances?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top