Solved

Non-Serializable and MarshalByRef Objects

Posted on 2004-03-26
2
1,103 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

816 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

7 Experts available now in Live!

Get 1:1 Help Now