Solved

Non-Serializable and MarshalByRef Objects

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

24 Experts available now in Live!

Get 1:1 Help Now