Public Shared Variables are lost their values

  • Thread starter Thread starter Murat Fidan
  • Start date Start date
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
 
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?

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
 
Back
Top