Unable to serialize the session state

Can we see the “Gebruiker” class? There error seems straightforward enough. Gebruiker is not attributed as being Serializable therefore it can’t be placed in Session for StateServer and SQLServer modes.

EDIT:

After looking at the code you linked in, yes, it’s probably because the class isn’t serializable. The LINQ generated class should be a partial class so you can implement your own partial class that marks it as Serializable and the sessionstate requirements will be met then.

[Serializable()]
public partial class Gebruiker { //Lots of stuff }

EDIT 2:

Thomas, your Gebruiker class probably has a definition that looks like this right now (or something similar)

namespace XYZ
{
   public partial class Gebruiker
}

Just create another class file that has the same namespace and define the class with the Serializable attribute

namespace XYZ
{
  [Serializable()]
  public partial class Gebruiker{}
}

That’s all you should need in this file. This way, the serializable attribute won’t be overwritten when the LINQ generated Gebruiker class gets created.

Leave a Comment