Serializing an object from a DLL

G

Guest

I am using SQL to hold session state. My problem is that I have an object
that I want to store in Session State. I can not mark the class it comes from
as Serializable because it is from a DLL that I do not have the code for.
There must be an easy way to do this I just can't figure it out.


This is the code that Serializes the item that I want to place in a Session.

private string Serialize(SessionStateItemCollection items)
{
MemoryStream ms = new MemoryStream();
BinaryWriter writer = new BinaryWriter(ms);

if (items != null)
items.Serialize(writer);

writer.Close();

return Convert.ToBase64String(ms.ToArray());
}

I'd really appreciate anyone who could help.
 
G

Guest

unless its sealed, make a new object that inherits from it, and enable
serialization.

the underlying object may not really support serialization (use of unmanged
code, active streams / connections, non-serializable objects). in this case
you can write a custom serializier read/write out the properties, and
perform required initialization.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top