note: some object can not be serialized, such as sqlconnections,
datareaders, streams, com interop objects, collections containing a
non-serializable object, etc. in this case you must be redesign you session
data.
you'd think, when asp.net tried to serialize session data, it would list the
name of the object. to find the offending object:
try (air code)
MemoryStream myWriter = new MemoryStream ();
foreach (string key in Session.AllKeys)
{
object o = Session[key];
try
{
XmlSerializer mySerializer = new XmlSerializer(o.GetType());
mySerializer.Serialize(myWriter, o);
}
catch
{
Debug.Print("Unable to serialize: " + key);
}
}
myWriter.Close();
-- bruce (sqlwork.com)
-- bruce (sqlwork.com)
"Winista" <na*********@hotmail.com> wrote in message
news:O4**************@TK2MSFTNGP02.phx.gbl...
If there is something that does not need to be serialized, make them
non-public or decorate then with Non-serialzable attribute. You will have
to look at your objects closely to make the decision. and if there is
something that needs to be serialzable and by default does not do it by
itself then you will have to manually serialize those objects.
Also put [Serializable] attributes on your objects.
"NAT" <NA*@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com... So do I need to serialize it ? How can i ?
"Winista" wrote:
Check all objects that you are storing in session. One of your objects
is
exposing an object as public property or field which is non serialzable.
An
example could be Thread object which is not serialzable.
Winista
http://www.universalshoppingmall
"NAT" <NA*@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
>
> I was using session mode as "InProc"(entered in web.config). I have
> deployed
> my ASP.NET appln. on a server which uses Load Balancer. i.e I have two
> servers. I am using session across pages.The problem I was facing is
> that
> sometimes I find the session and sometimes not. I beleive this is
> happenning
> because of multiple servers. Because session is created on a worker
> process
> on one server and the second time it must be hitting the other server
> to
> fetch the
> session. Hence the issue.I then used SQL Server session mode but now I
> get
> the errror "Unable to serialize the session state. Please note that
> non-serializable objects or MarshalByRef objects are not permitted
> when
> session state mode is 'StateServer' or 'SQLServer'. "
> Any Idea ? Thanks in advance..