Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode...

 Dear Fellows, I am having a problem in my asp.net application

i 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 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 more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: 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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
  Stack Trace:

[SerializationException: Type 'System.Data.DataRow' in Assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +2700482
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +245
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +88
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) +293
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) +46
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteArray(WriteObjectInfo objectInfo, NameInfo memberNameInfo, WriteObjectInfo memberObjectInfo) +2696211
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +152
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +489
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +131
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1513

[HttpException (0x80004005): 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.]
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1602
System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer) +34
System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter writer) +627
System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream) +257
System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length) +60
System.Web.SessionState.OutOfProcSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +87
System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +476
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64



Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

 

What i m doing in my appliation is

Initializing a DataRow 

 DataRow[] row ;

 Its gives me the error when i try to access this part of my code (Given Below)

else
            {
                
Session["userinfo"] = row;            // <<<Error Must be here
                Label2.Text = row[0].ItemArray.GetValue(1).ToString();
                MultiView1.ActiveViewIndex = 1;
            }

I m Surprised That the same application working fine in VS and local IIS with WEB MS SQL server

Kindly help    


aliusmankhan
C#
.NET 3.5
Web.Dev
AJAX
0
aliusmankhan
7/2/2008 1:20:07 PM
asp.net.state-management 8807 articles. 0 followers. Follow

7 Replies
1157 Views

Similar Articles

[PageSpeed] 46

The DataRow cannot be serialized. Refer to this post.

http://thedotnet.com/nntp/451421/showpost.aspx 

0
santa_1975
7/2/2008 1:36:44 PM

santa_1975:

The DataRow cannot be serialized. Refer to this post.

http://thedotnet.com/nntp/451421/showpost.aspx 

 

Thasnk you for reply But  what is wrong with my application on web?
because i am not using any [serialization]  in my application, If i cant save datarow in my session then what should i do, should i try to save it in cache? and y its working fine in local IIS?



aliusmankhan
C#
.NET 3.5
Web.Dev
AJAX
0
aliusmankhan
7/2/2008 1:41:23 PM

You can't serialize a DataRow, but I'm pretty sure you can serialize a DataSet. So fill a DataSet with the datarow and you should be fine. I'm not saying it's a GOOD solution, but it should work.

Another option, is to simply create your own serializable class/structure and then transfer the data from the DataRow into the instance of the class/structure, then assign the instance to Session.

 

THe reason it's working fine locally, is that you're not using Sql Server to store the session-data, and then the objects doesn't have to be serializable since they're saved in memory. But when using SQL Server to store the session data, the data needs to be serialized into a binary field.

0
Phr34ker
7/2/2008 2:27:05 PM

Serializing DataSet will be pretty heavy. Try to put your DataRow content into separate Session Variables like

Session["UseName"] = <User Name value from the DataRow>;

0
santa_1975
7/2/2008 6:20:42 PM

santa_1975:

Serializing DataSet will be pretty heavy. Try to put your DataRow content into separate Session Variables like

Session["UseName"] = <User Name value from the DataRow>;

And if you do, make sure to clean up the terrible mess that this will cause with all the persistent session-variables that will follow the user until his session is abandoned or times out, by calling Session.Remove("nameOfTheProperty") on every single Session-property that you've created one you're finished with it.

0
Phr34ker
7/3/2008 8:21:52 AM

try this

bytes.com/forum/thread299294.html

ytes.com/forum/thread299294.html

aspalliance.com/1066_Session_State_Management.4

 

0
itsumapathyk
7/3/2008 8:57:47 AM

 

Thank You So Much All Of You

I Wil look out it later, For now i but datarow's each element in separate session and i put dataset in Cache, Later i wil remove Dataset from cache,

In long term i wil serialize dataset as u all friends said 

Thank You so Much 


aliusmankhan
C#
.NET 3.5
Web.Dev
AJAX
0
aliusmankhan
7/4/2008 5:56:27 AM
Reply:

Similar Artilces:

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.Serializa...

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 ...

'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...

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...

table_info('','','','%') cannot return any types
I was recently confirming table_info special cases and discovered the case for getting table_types cannot work. table_info('','','','%') should return a list of table types but it returns a list of empty strings instead: my @types = $h->tables('', '', '', '%'); print "all types:\n", join("xxx\n", @types), "\n"; # should output something like: # "dbo" # "INFORMATION_SCHEMA" # "sys" # and actually outputs: xxx xxx It seems to be down to the following ...

'b'..'a'
Hello. I'm using defferent 5.6.0's for Win32. I wonder wheter following behaviour is intentional or not: d:\>perl -e "print 'b'..'c'" bc d:\>perl -e "print 'b'..'a'" bcdefghijklmnopqrstuvwxyz I expected empty list in latter case, like in perl -e "print 'bb'..'a'" <!ENTITY Vadim REALLIFE "Vadim V.Konovalov, St.Petersburg, Russia"> &Vadim; On Wed, Sep 20, 2000 at 03:14:41PM +0400, Konovalov, Vadim wrote: > Hello. > > I'm using defferent 5.6.0'...

'or' or 'union'
Hello I was just wondering, in general what is better to use, an 'or' clause in a select or a 'union' to join two selects together. Do both statements create work tables? Many thanks Alex I think OR will be better than union. because suppose u have 3 tables and using OR u can join table a and table b and table c so each table will have only one read. but using union you will join table a and table b and in another query of union u will use table (a or b) and table c so ur one read is more in union . Ramdas Alex Cheung wrote: > Hello > >...

'IN' Clause or 'OR'
Hello, [1]: select * from TABLEA where COL1 IN('value1','value2''valu3'....) [2]:select * from TABLEA where COL1 = 'value1' OR COL1= 'value2' OR COL1='valu3'. TABLEA is a huge table and it has non-clustered index on COL1. Among the above 2 queries, which query will give me the better performance or fast response and WHY? What is the difference between 'IN' and 'OR' clauses as for as Sybase Optimization is concerned. Which is the better one to be used on huge tables. Thanks. Mac An IN list is treated ...

'To', 'CC', & 'BCC'
Name: Dick Tracy Email: philipdottracyatoptusnetdotcomdotau Product: Thunderbird Summary: 'To', 'CC', & 'BCC' Comments: I have just started using Thunderbird and while I find it quite excellent- I suggest having a button to add addressees to 'BCC' as well. Currently each 'BCC' addressee has to be selected manually. I send e-mail to quite a number of people at a time and I do not wish to readily spread others addresses easily. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0....

EXEC sp_msforeachtable 'sp_spaceused ''?'''
What does the following SQL code mean?  EXEC sp_msforeachtable 'sp_spaceused ''?'''Johan TheunissenMCPD, MCSE, MCTS BizTalk 2006==============================Please mark the most helpful reply/replies as "Answer". JohanNL:sp_msforeachtable This is the name of the SP that resides in the master database.  This SP executes one or more commands for a table. JohanNL:sp_spaceused This is the command that you want to run for each of the tables residing in your current database.  As you might have understood so far, that this is again a...

Web resources about - Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode... - asp.net.state-management

Resources last updated: 2/4/2016 10:10:58 AM