I am storing an object in session state (using local session state server), class def is:
[Serializable]
public class ExtendedOAuth2Parameters : OAuth2Parameters
but the service is still reporting:
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.
[SerializationException: Type 'Google.GData.Client.OAuth2Parameters' in Assembly 'Google.GData.Client, Version=2.1.0.0, Culture=neutral, PublicKeyToken=04a59ca9b0273830' is not marked as serializable.]
How to get around it?
Based on the error message, it looks like the base class (Google.GData.Client.OAuth2Parameters
) is not serializable, so even though you have marked your class with the Serializable
attribute, the complete class hierarchy is not.
You would either need to use a bass class that is itself serializable, or if you have access to the code (probably don't?), make the Google.GData.Client.OAuth2Parameters
class serializable.
Keep in mind that 'serializability' is dependent on the complete type tree for any given class - i.e. all base classes and member classes also need to be serializable for the enclosing class to be truly serializable.