Solved

Non-Serializable and MarshalByRef Objects

Posted on 2004-03-26
2
1,102 Views
Last Modified: 2007-12-19
Hi All,

I'm working in an environment where Serialization is used.  While I basically understand why one would use Serialization, I don't really understand the programming specifics behind it.  I occasionally receive the following error as I build my pages, and don't understand what parts of my code cause it:

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

These errors SEEM to be related to my use of Session vatiables -- though I'm really not sure.

Does anyone out there have any idea of general guidelines to follow when programming in an environment where Serialization is used in order to avoid such errors.  Perhaps a link to an article?

Thanks much,

K
0
Comment
Question by:kaubey
2 Comments
 
LVL 1

Accepted Solution

by:
NotaClue earned 250 total points
ID: 10689204
Hi K,

It is related to your session variables, it is easily solved, if you have a session vaiable that is a clas you created, just add the
serializable attibute to at the beginning of the class declaration

<Serializable()> Public Class Yourclassname

This adds code behind the scenes to your class be serialized and thus usable with session state  'StateServer' or 'SQLServer'
the alternative, which doesn't seem to be an option here, is to change the session state to InProc, then you don't have to worry about serialization :)

as for articles go to google and search asp.net and serialization there are lot of articles, but here are a couple to get you started..

http://www.4guysfromrolla.com/webtech/012302-1.shtml

http://msdn.microsoft.com/msdnmag/issues/02/04/net/default.aspx

0
 

Author Comment

by:kaubey
ID: 10689428
Thanks NotaClue --  This info was exactly what I was looking for.  I wish I had the option to change the session state to InProc, but the powers that be lay down such laws:-)

Regards,

K
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now