Unable To Serialize The Session State In State Server And Sql Server Mode Sharepoint

Hi All, My website session was expired within seconds. I tried every possible solution but problem was same.( ) Now i changed my session mode to stateserver, but when i logout from website its giving error. Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode. 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.Web.HttpException: Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted.
Session state data is shared across all the web pages, in other words when navigating from one page session the data would available. Here are the various session modes available in ASP.NET. InProc; StateServer; SQLServer. I have created a sample Asp.Net application which will have two pages. Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
Give More Feedback

The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode. I have mention Serializable on class. And some of hyper links also not working after changing the mode to stateserver. Please help.
Session states are of different types or modes The production site must be using a outProc session state in which only serializable objects can be stored. U r storing in all probability a custom class object or something like a data table in a session variable which is not serializable. This error is thrown because the DockState is not marked as serializable and ASP.NET requires the objects to be serializable to store them in the Session (when mode is 'StateServer' or 'SQLServer'). To overcome this problem you should serialize the state 'manually' before it is stored in the Session.
Refer Hope it helped. Session states are of different types or modes The production site must be using a outProc session state in which only serializable objects can be stored. U r storing in all probability a custom class object or something like a data table in a session variable which is not serializable. This error is thrown because the DockState is not marked as serializable and ASP.NET requires the objects to be serializable to store them in the Session (when mode is 'StateServer' or 'SQLServer'). To overcome this problem you should serialize the state 'manually' before it is stored in the Session. Refer Hope it helped.