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'

 Hi,

We are trying to implement Network loading for our asp.net (1.1) application for which we are storing the session in State Server.

Following is the error is thrown while page is rendered when ever is a DTO is stored in to SEssion in any of the page.

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'

 Following the code I written for DTO (C# Asp.net 1.1).

     using System;
    using System.Runtime.Serialization;


// CLASS      : NewUserDTO.cs
// DESCRIPTION: NewUserDTO class sets or gets all field values into the properties.
/
//*********************************************************************
//
// REVISION HISTORY
// ----------------
// Date           Who             Description
// ---------- --- -----------------------------------------------------
//
//*********************************************************************

namespace US.WY.SEO.ePermit.Common.Data
{
    /// <summary>
    /// Summary description for NewUserDTO.
    /// </summary>
    ///
    
    [SerializableAttribute]

    public class NewUserDTO
    {
        #region Private Variables

        private string        _strFirstName            = string.Empty;
        private string        _strLastName            = string.Empty;
        private string        _strLoginID                = string.Empty;
        private string        _strBusinessTitle        = string.Empty;
        private string        _strCompany                = string.Empty;
        private string        _strAddress1            = string.Empty;
        private string        _strAddress2            = string.Empty;
        private string        _strCity                = string.Empty;
        private string        _strState                = string.Empty;
        private string        _strZip                    = string.Empty;
        private string        _strCountry                = string.Empty;
        private string        _strPhone1                = string.Empty;
        private string        _strPhone2                = string.Empty;
        private string        _strFax                    = string.Empty;
        private string        _strEmailID                = string.Empty;
        private string        _strStatus                = string.Empty;
        private string        _strRole                = string.Empty;
        private string        _strRegulatoryFunction    = string.Empty;
        private string        _strModifiedDate        = string.Empty;
        private string        _strCreatedBy            = string.Empty;
        private Role[]        _arrRoles;
        private RegulatoryFunction[]        _arrRegulatories;

        #endregion

        #region Constructor
        public NewUserDTO()
        {
            
        }
        #endregion

        #region Properties

        public string FIRST_NAME
        {
            get{return _strFirstName;}
            set{_strFirstName = value;}
        }

        public string LAST_NAME
        {
            get{return _strLastName;}
            set{_strLastName = value;}
        }

        public string LOGIN_ID
        {
            get{return _strLoginID;}
            set{_strLoginID = value;}
        }

        public string BUSINESS_TITLE
        {
            get{return _strBusinessTitle;}
            set{_strBusinessTitle = value;}
        }

        public string COMPANY
        {
            get{return _strCompany;}
            set{_strCompany = value;}
        }

        public string ADDRESS_1
        {
            get{return _strAddress1;}
            set{_strAddress1 = value;}
        }

        public string ADDRESS_2
        {
            get{return _strAddress2;}
            set{_strAddress2 = value;}
        }

        public string CITY
        {
            get{return _strCity;}
            set{_strCity = value;}
        }

        public string STATE
        {
            get{return _strState;}
            set{_strState = value;}
        }

        public string ZIP
        {
            get{return _strZip;}
            set{_strZip = value;}
        }

        public string COUNTRY
        {
            get{return _strCountry;}
            set{_strCountry = value;}
        }

        public string PHONE_1
        {
            get{return _strPhone1;}
            set{_strPhone1 = value;}
        }

        public string PHONE_2
        {
            get{return _strPhone2;}
            set{_strPhone2 = value;}
        }

        public string FAX
        {
            get{return _strFax;}
            set{_strFax = value;}
        }

        public string EMAIL_ID
        {
            get{return _strEmailID;}
            set{_strEmailID = value;}
        }

        public string STATUS
        {
            get{return _strStatus;}
            set{_strStatus = value;}
        }

        public string ROLE
        {
            get{return _strRole;}
            set{_strRole = value;}
        }

        public string REGULATORY_FUNCTION
        {
            get{return _strRegulatoryFunction;}
            set{_strRegulatoryFunction = value;}
        }

        public string MODIFIEDDATE
        {
            get{return _strModifiedDate;}
            set{_strModifiedDate = value;}
        }
        public string CREATEDBY
        {
            get{return _strCreatedBy;}
            set{_strCreatedBy = value;}
        }
        
        public Role[] ARR_ROLES
        {
            get{return _arrRoles;}
            set{_arrRoles = value;}
        }
        
        public RegulatoryFunction[] ARR_REGULATORIES
        {
            get{return _arrRegulatories;}
            set{_arrRegulatories = value;}
        }
        

        #endregion

        public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
                    
            // TODO:  Add WellLogDTO.GetObjectData implementation
        }
    }
    
    [SerializableAttribute]
    public class Role
    {
        #region Private Variables

        private string        _strRoleCode            = string.Empty;
        private string        _strRoleDesc            = string.Empty;
        
        #endregion
        #region Constructor

        
        public Role()
        {            
        }
        #endregion
        #region Properties

        public string ROLE_CODE
        {
            get{return _strRoleCode;}
            set{_strRoleCode = value;}
        }
        public string ROLE_DESC
        {
            get{return _strRoleDesc;}
            set{_strRoleDesc = value;}
        }
        #endregion
    
    }
    
    [SerializableAttribute]
    public class RegulatoryFunction
    {
        #region Private Variables

        private string        _strRegulatoryCode            = string.Empty;
        private string        _strRegulatoryDesc            = string.Empty;
        
        #endregion
        #region Constructor
        public RegulatoryFunction()
        {            
        }
        #endregion
        #region Properties

        public string REGULATORY_CODE
        {
            get{return _strRegulatoryCode;}
            set{_strRegulatoryCode = value;}
        }
        public string REGULATORY_DESC
        {
            get{return _strRegulatoryDesc;}
            set{_strRegulatoryDesc = value;}
        }
        #endregion
    
    }

    
}

NewUserDTO objDTO=new NewUserDTO();

And I am trying put thsi DTO into Session  Session[ objDTO];

When I am trying to retrive the values the error page is thrown with the message saying non seraizable objects were not stored in state server session.

 

 

Please correct andadvice me to resolve this issue.

 The project is in delivery stages and we implemented satte server now...The error is comming in 75% of the application.

 

Your quick response will be highly appreciated. 

 

 

Thanks,

 

Venkatesh Varakala
 

 

0
VenkateshVarakala
1/25/2008 2:32:14 PM
asp.net.state-management 8807 articles. 0 followers. Follow

1 Replies
1608 Views

Similar Articles

[PageSpeed] 32

The cause of your problem is that you're trying to serialize something that's considered unserialized by the framework.  You have a few options:

1) If it's something that doesn't need to be deserialized later, or can be instantiated at any time if it's not available, then you can just mark the variable with the

[NonSerialized] attribute.

2) If you have the source code, you can modify the offending object and change it to be serializable ( sometimes all you have to do is add the [Serializable] attribute to the class )

3) Switch to in-process state server

Hope this helps!

Colin

0
ColinWhitlatch
1/25/2008 7:19:42 PM
Reply:

Similar Artilces:

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode...
 Dear Fellows, I am having a problem in my asp.net applicationi made a online testing system, This system is running Fine on my local VS and also in local IIS (While Using Web MS SQL Server)But when I host this web site it gives me the error when i try to add an object in session[] Error Is - SETS is the name of my visual Directory Server Error in '/sets' Application.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 ob...

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode
i got this error... anyone encountered this yet? Server Error in '/MainLogin' Application. 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. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for mor...

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode.
Hi Every one,First of all thank you everyone.Please help me to figure out this problem. I am building shopping cart in my global.asax (snippet),   <script runat="server">    void Application_Start(object sender, EventArgs e)     {        Application.Clear();     }        void Application_End(object sender, EventArgs e)     {        Application.Clear();        Session.Ab...

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

'''''
Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

Argument '1': cannot convert from 'object' to 'int'
 I am calling a function from a label control in my gridview.. <asp:Label ID="Label1" runat="server" Text='<%# ShowCategoriesForPID(Eval("pol_id")) %>'/> But i get following error when i compile -error CS1503: Argument '1': cannot convert from 'object' to 'int'  pol_id is an integer value and my function receives it as an integer argument.  I dont know whats wrong? The "Eval" function returns an object. To need to cast it's result: <asp:Label ID="Label1" runat="s...

Could not find control 'DropDownList1' in ControlParameter 'state'
This is my first attempt with the beginners walkthrough using the VWD2005 beta 2.  Overall I'm getting a handle on it but I made a mistake sometime back in the DataList/DataSource lessons that keep coming back to haunt me.  The following is the statement I get when I try to run the site:  Server Error in '/WebSite1' Application. Could not find control 'DropDownList1' in ControlParameter 'state'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it ...

Unable to cast object of type 'System.Object[]' to type 'System.Data.DataView'.
I am tring to retieve a single node from my BLL code which retrieve one instane of Repot object:DataView dv = (DataView)objBoutPrep.Select();I am getting error:Unable to cast object of type 'System.Object[]' to type 'System.Data.DataView'. The BLL code returns onle one object and not a list of objects.Please help Client code: <asp:ObjectDataSource ID="objBoutPrep" runat="server" SelectMethod="GetRByID" UpdateMethod="UpdateT" TypeName="MB.K.BLL.G.Report"> <SelectParameters> <asp:Query...

The 'MAPI Session Handle' of the Novell GroupWise 'Object Request Broker' could not be accessed.
Getting this error: The 'MAPI Session Handle' of the Novell GroupWise 'Object Request Broker' could not be accessed. When I open GW I recently upgraded the machine from 98SE to WinXP (I know it's not suggested, but I was lazy and bored and wanted to see how it would respond). I have tried to remove GW all the way, and that doesn't seem possible, or at least very easy. I am running GW 65 SP1 on NW 65 SP1, machine is XP Pro SP1 Any idea how to get that error. GW loads fine, but when I try to open a new email, open the address book, etc, I get this. I thi...

'do' won't 'do' if '/'
Greetings to All from Au, Have a NetWare Perl 5.8.4 and wanted to tweak File\Spec\NW.pm to try and standardise on '/' separators. If I run a test script (t/uni/lower.t) with an unmodified NW.pm, it calls t/uni/case.pl, that, in case.pl, (when the path separators are '\'), the $file is '..\lib\unicore\To\Lower.pl' and the following code portion works, with $simple getting a returned table: sub casetest { my ($base, $spec, $func) = @_; my $file = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "lib", &qu...

'''
Name: L Lachowsky Email: e2brutus_10atyahoodotcom Product: Firefox Summary: ''' Comments: why duddn this surprise me... I change default server from IE to Mozilla, and then i get error messages. well, shud I decide to not get on my computer with Mozilla..or shud I risk security breeches with IE....hmmm at least i can get on the internet with IE Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this fee...

Operator '==' incompatible with operand types 'Int64' and 'Object'
I have the typical gridview control driving a formview control.  Both use LinqDataSources.  I'm using the table's ID field, DelID to find the record to be displayed by the FormView when a record is selected from the GridView.  This gives me the above error.  Why, and how do I fix this?Diane Check the type of the operands you are trying to compare.You will have to cast on your operands. something like intvariable == (int)objectvariable; or if(((object)intvariable).Equals(objectvariable))*** If this post helps you, then Mark this post as Answer *** I'm ...

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

bless() bug ? Why fails reblessing of 'main::Object' to 'Object' ?
After a short thread in comp.lang.perl.misc: bless() does not change 'main::Object' to 'Object', but UNIVERSAL::isa() does distinguish them. What to do ? Shall i override the bug with a selfmade CORE::GLOBAL::bless() sub, but how ? Here the relevant discussion: > "Murat Uenalan" <murat.uenalan@gmx.de> writes: > > > Here my test... > > > > <perl> > > > > require 5.005_62; use strict; use warnings; > > > > my $class = "main::User"; > > > > my $this = bless ...

Web resources about - 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' - asp.net.state-management

Resources last updated: 11/26/2015 6:15:27 AM