Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: Session Data Is Not Saved in Out-of-Process Session State


View products that this article applies to.

Symptoms

When you use SQLServer session state mode, if you try to store an instance of a class that is not marked as serializable into a session variable, the request returns without an error. However, ASP.NET actually fails to save the session data and blocks subsequent requests in the same session.

This same behavior occurs when you use StateServer session state mode, but you also receive the following run-time error:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.Serialization.SerializationException: The type <namespace.classname> in Assembly <AssemblyName>, Version=1.0.676.30211, Culture=neutral, PublicKeyToken=null is not marked as serializable.
When session state is configured to be stored in Microsoft SQL Server, the thread that processes your request hangs, and the TempGetStateItemExclusive stored procedure in the ASPState database is called continuously with the same values in one-second increments. If session state is set to InProc, everything works as expected.

↑ Back to the top


Cause

This problem occurs because the class is not marked as serializable.

↑ Back to the top


Resolution

To resolve this problem, add the [Serializable] attribute to mark the class as serializable. For example, use the following Microsoft Visual C# .NET code:
[Serializable]
public class MyClass
{
  //class code
}
				
Or use the following Microsoft Visual Basic .NET code:
<Serializable()> _
   Public Class MyClass
     'Class code
   End Class
				
Note If the class uses other classes, you must mark each class as serializable. The problem in this article also occurs with some Microsoft .NET Framework classes such as the XmlDocument class. These classes cannot be marked as serializable, so the error will still occur.

↑ Back to the top


Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This bug was fixed in ASP.NET (included with the .NET Framework) 1.1.

↑ Back to the top


Properties

Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

↑ Back to the top


Keywords: KB312112, kbstate, kbreadme, kbnofix, kbbug

↑ Back to the top

Article Info
Article ID : 312112
Revision : 5
Created on : 8/3/2003
Published on : 8/3/2003
Exists online : False
Views : 480