In a nutshell, I'm unable to add a reference to a WCF service to the Session object in a SharePoint 2010 application page, because it claims that the object is non-serializable. Further details:
SessionState support has been enabled in SharePoint (which uses SQL SessionState), and I'm trying to persist a reference to my WCF connection into the Session object, since the WCF connection is stateful. I know that WCF should ideally be stateless, however
the WCF server is initializing some objects that are expensive to intialize, and we need it to try and persist the data per session as much as possible. The same WCF service also in use by a standard ASP.NET application, which has no issues since
it uses in-memory sessions, which do not require serialization.
The problem is that the WCF proxy class is not marked serializable (and editing the proxy class to mark it serializable doesn't help), and therefore adding it to the Session fails because in SharePoint / SQL SessionState all objects must be binary serializable.
Exact error is:
Exception type: SerializationException
Exception message: Type 'Contoso.CNDataServiceClient' in Assembly 'Contoso.Wss4Pages, Version=220.127.116.11, Culture=neutral, PublicKeyToken=123b132913982371' is not marked as serializable.
I was wondering if anyone had any guidance / suggestion
View Complete Post