Why is that if I restart IIS, a static variable’s data is lost (e.g. in a webpart property in Sharepoint) but in an instance variable, this is not the case?
This is with IIS7 and Windows Server 2008 R2 x64.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If a process is restarted, all variables are lost.
But: IIS automatically serializes the session variables into another processes memory when a pool is recyled. When the pool restarts, the session variables are deserialized and thus, restored.
This is done with the .NET serialisation feature, which means that all session variables has to be marked with the [Serializable] attribute, otherwise you get runtime excpetions.