Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 1881

Binary Formater Serialize Error

$
0
0

Hi All,

I am creating a Component Using C#.Net, theme of this component is, Handling the Session management, as part of this, i have Dictionary<string, Object>. so all the session values are placed in this dictionary,

i am trying to Serialize this dictionary with Memory Stream and Binary Formater and convert to Byte[] then, stored in DB.

reverse process, Deserializing then convert to Dictionary object.

while Serialize i am getting below error.

Note: after successfull creation of component, i register the component in component services and called inclassic asp page,

Error Details

Type 'System.__ComObject' in Assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

MyCode:

byte[] buff = null;
            using (MemoryStream mStream = new MemoryStream())
            {
                try
                {
                    BinaryFormatter binFormat = new BinaryFormatter();
                    binFormat.Serialize(mStream, m_Session);   -> Here i am getting error.
                    buff = mStream.ToArray();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("SaveSessionData - Serialize", ex.Message + ex.StackTrace, EventLogEntryType.Error);
                    throw;
                }
            }

ASP Page Code

dim testmsg
set testmsg = Server.CreateObject("SessionManagement.sessionMng")

dim con
    set con = Server.CreateObject("ADODB.Connection")
    con.open testmsg.ConnectionSTring
    testmsg("objconn") = con  -> Here i could like to Hold Connection Object in Session

 this ADODB.Connection object going to my Component Dictionary as a value. that time i am getting error while Serialize.

Some one can help me ? Thanks in Advance

---Chandra Mohan


Viewing all articles
Browse latest Browse all 1881

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>