Unable to Serialize

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I am getting the error:

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

I have a .DLL that has 4 classes:

<Serializable()> Public Class POP3Client
<Serializable()> Public Class EMail
<Serializable()> Public Class SMTPClient
<Serializable()> Public NotInheritable Class MailAttachment

The only Class I am trying to put in a session is a POP3Client object. But
I am getting this error. The .DLL compiles fine with no errors. So why
would I get this error????

Thanks,

Tom
 
I also am using Sockets as I am getting mail from our Exchange Server.

Could this be part of the problem?

Thanks,

Tom
 
the serialization code is generated at runtime, the first time you ask
an object to be serialized, so serialization error are only found at
runtime.

the <Serializable> attribute declares the class serializable, it does
nothing else, it will not make it magically so. if its your own class
you may be able to make it serializable by property attributes or
writing your own serialization code.

if your class is really a pop3 connection, to serialize you will need to
store the connection state, and reopen the connection on in your
deserialization code.

-- bruce (sqlwork.com)
 
bruce barker said:
the serialization code is generated at runtime, the first time you ask an
object to be serialized, so serialization error are only found at runtime.

the <Serializable> attribute declares the class serializable, it does
nothing else, it will not make it magically so. if its your own class you
may be able to make it serializable by property attributes or writing your
own serialization code.

if your class is really a pop3 connection, to serialize you will need to
store the connection state, and reopen the connection on in your
deserialization code.

Here is a portion of my code:
********************************************************

Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Imports System.Threading
Imports System.IO
Imports System.Collections.Specialized

<Serializable()> Public Class POP3Client
Protected sockPOP3 As Socket
Protected m_Port As Int16 = 110 'Use default POP3 port 110
Protected m_Remote As IPEndPoint
Protected m_User As String
Protected m_Pass As String
Protected m_arrMailList As New ArrayList
Protected m_WaitBeforeReceive As Boolean = True

Protected Const SendBufferLength As Int16 = 1023
Protected Const ReceiveBufferLength As Int32 = 65535

Private bufferReceive(ReceiveBufferLength) As Byte
Private bufferSend(SendBufferLength) As Byte


Public Sub New()
sockPOP3 = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)
sockPOP3.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReceiveTimeout, 60000) 'Timeout: 60 sec
sockPOP3.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.SendTimeout, 60000) 'Timeout: 60 sec
End Sub

********************************************************

Are you saying I need to tak the Socket section out of my code since it has
the connection information in it and do something else with it?

Thanks,

Tom
 
Back
Top