开发者

SQL Server Session State causing Serialization error

开发者 https://www.devze.com 2022-12-12 22:46 出处:网络
I have an .Net 3x application using default WCF serialization and recently setup application to use SQL Server Session state and am not being able to store those objects in session state with sql serv

I have an .Net 3x application using default WCF serialization and recently setup application to use SQL Server Session state and am not being able to store those objects in session state with sql server, only in proc session state.

Getting errors on various classes stating:

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 assumed that the default serialization of wcf would be sufficient but apparently not. A开发者_运维问答ny ideas on what needs to be done to correct this short of editing entire app and adding [Serializable] to classes?


It seems like you have four choices:

  1. Switch back to InProc mode
  2. Make your objects [Serializable]
  3. Instead of storing high-level container objects in the Session dictionary, use lower-level objects instead, that are already serializable (such as strings, ints, etc)
  4. Avoid using traditional session state, and switch to some alternative state management method instead

Option 3 will generally run faster than 2, although it's also more work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号