Session state not storing or saving gotcha

Hi folks,

Recently in my SP-CRM project I noticed that my session state that I enabled in SharePoint doesn't use SQL Server for storage (it uses inproc). Although it works fine so far, but the recommended way is to enable sessionstateservice using Enable-spsessionstateservice powershell cmdlet.

So I did this, and my application was broken. After debugging, I realized it could not store my object into the session table in the database. I read up documentation and the requirement for storing object is that the object must be serializable.

I checked my class and it already had serializable attribute. However, there is a property with the type of the generated class created by crmsvcutil and I had a feeling this was the culprit, and I was right!

The solution is to not use any of the crmsvcutil generated class in your session variables, otherwise you wouldn't be able to save it.