TheWizardofInt Posted June 26, 2006 Posted June 26, 2006 Normally, I will instantiate a class for global variables with a section like so: Private m_FullName As String Private m_Identity As System.Security.Principal.WindowsIdentity Private m_URL As String Shared myInstance As globVars Private Sub New() m_Identity = System.Security.Principal.WindowsIdentity.GetCurrent() m_FullName = m_Identity.Name End Sub Public Shared Function GetInstance() As globVars If myInstance Is Nothing Then myInstance = New globVars End If Return myInstance End Function '/ insert properties here Then invoke the class: Dim glob as globVars glob = globVars.GetInstance And start using variables. This works over a network environment, but not so hot in an Internet environment, I believe because the Application doesn't really close if everyone is on it. I tried setting the class to nothing in the Application.Close event - no luck. Any ideas as to what I am doing or not doing wrong here? Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
Administrators PlausiblyDamp Posted June 26, 2006 Administrators Posted June 26, 2006 Global variables and asp.net applications are a really difficult mix and you need to be very careful about how you use them. Application variables will remain until the application exits and it's only then that the application_close event will fire. If you wish to remove the class when a user disconnects then the session_end may be a more appropriate place. However you will probably still get the potential for problems with your code due to the use of shared data members. It may be easier to design the class to use instance data rather than shared data and then store it in either the application or session based on the requirements of your app. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
TheWizardofInt Posted November 6, 2006 Author Posted November 6, 2006 What do you mean specifically by 'use instance data'? Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.