SQL Server session not working...

Discussion in 'ASP .Net' started by =?Utf-8?B?TkFU?=, Jun 14, 2006.

  1. 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..
    =?Utf-8?B?TkFU?=, Jun 14, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?TkFU?=

    Winista Guest

    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" <> wrote in message
    news:...
    >
    > 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..
    Winista, Jun 14, 2006
    #2
    1. Advertising

  3. 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" <> wrote in message
    > news:...
    > >
    > > 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..

    >
    >
    >
    =?Utf-8?B?TkFU?=, Jun 14, 2006
    #3
  4. =?Utf-8?B?TkFU?=

    Winista Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    >> news:...
    >> >
    >> > 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..

    >>
    >>
    >>
    Winista, Jun 14, 2006
    #4
  5. 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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >> 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" <> wrote in message
    >>> news:...
    >>> >
    >>> > 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..
    >>>
    >>>
    >>>

    >
    >
    bruce barker \(sqlwork.com\), Jun 14, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William \(Bill\) Vaughn
    Replies:
    0
    Views:
    441
    William \(Bill\) Vaughn
    Aug 21, 2003
  2. David Browne
    Replies:
    0
    Views:
    455
    David Browne
    Aug 21, 2003
  3. Geoff
    Replies:
    3
    Views:
    440
    Patrick.O.Ige
    Jan 16, 2006
  4. MPF
    Replies:
    1
    Views:
    1,014
  5. sunkrajesh
    Replies:
    0
    Views:
    351
    sunkrajesh
    May 31, 2009
Loading...

Share This Page