Solved

Non-Serializable and MarshalByRef Objects

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
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.

828 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