Hei
Hei

Reputation: 513

Unable to serialize the session state, which is related to System.Data.Linq. EntitySet

Recently I am playing with the Windows Server 2008, and would like to make some configuration for my web application. I have changed the Session State for my application to "State Server" so it can make use of more work process (Now it is set to 4).

Afterwards I have got this error when I attempt to login to the application.

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.

I suspect it is related to the EntitySet I have declared because I see this in the Stack Trace when the error occur:

[SerializationException: Type 'System.Data.Linq.EntityRef`1[[CtcSystem.Domain.Entities.Account.Account, CtcSystem.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' in Assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.]

I have used [Serializable] tag on my classes, so is there any way I have to do to make the EntitySet serializable so that the application can run under State Server?

Thanks

Upvotes: 2

Views: 995

Answers (1)

130nk3r5
130nk3r5

Reputation: 1638

Best way is to implement the ISerializable interface on a partial class...

Upvotes: 0

Related Questions