Similar to This Question, I have an application that relies heavily on in-process session. I'm now trying to move the session store to a local State Server.
I'm getting the error:
Type 'System.Web.UI.Control' in Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
The problem is I can't determine which control is trying to be serialized.
The full exception and the stack trace doesn't show me any additional information.
Is there a way to determine what control is trying to be serialized?
Using ASP.net, IIS7, Framework 4.0
Do a global search for
Session[
orSession.Item
and find everything with the = to the right. That is all the assignments to Session. It can't me more than a few hundred. One of them is a System.Web.UI.Control. It was probably put into session to avoid hitting the database. Rewrite that code to store the DataTable or DataSet or other values instead of storing the Control.If you don't have the source code, there isn't an easy way to deal with this short of decompiling, fixing the code and recompiling.
Even if you give up on SqlSession, you may still want to stop putting UI controls into Session-- it can cause OutOfMemory problems: http://blogs.msdn.com/b/tess/archive/2008/05/28/asp-net-memory-thou-shalt-not-store-ui-objects-in-cache-or-session-scope.aspx