There are many questions that are similar to this...but I'm not seeing how they have this specific issue:
I have a webservice which returns an error that starts with:
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.
So, questions like this mention to look for SerializationException, find out what is unable to be serialized, and make it serializable. Sounds straightforward...but when I look for it, I find this:
[SerializationException: Type 'Microsoft.Web.Services3.StateManager' in Assembly 'Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.]
This confuses me...it sounds like it's actually trying to serialize the StateManager...is it just that it's hiding that something else inside is the StateManager is unable to be serialized? If so, is there a way to find out what? Or is the StateManager really supposed to be serializable for some reason? (I suspect I'm not stating this very clearly...sorry...if you have questions, I'll do my best to answer them.)
One thing that I should also note is that we're using NCache as a session store provider, which seems like it could possibly be related in some way. But it's not clear to me how that could cause what I'm seeing.
If you are serializing a custom object make sure to decorate the class with the attribute. Without this on any object that you put into the session state the serializer will fail. You probably need to isolate the item you are storing and check it's properties and that it itself has that attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With