1

I have a small query. I need to create a Caching Service of my own that will write and read .NET Objects to and from the Database. Now, I have achieved that with the help of Binary Serialization. But the Problem is I need to deliberately marked my objects as [Serializable], which makes me think that what if someone will try to add an object which is not marked as [Serializable].

Thus, I need to find a way to read and write Objects to Database without Serialization.

I have one thought too.. As we all know Session can store any object in it. Now, we can make sessions to be stored in the DB, outproc. What mechanism it uses to store these objects without serializing or deserializing.

Any help will be highly appreciated.

Thanks. M.B

2
  • 5
    Objects stored in a session backed by a database must be serializable. It is not just a switch to flip. You must serialize in some way to store the data in a database. Commented Jan 11, 2011 at 2:52
  • So that simply means that whenever we try to save something in session its is being serialized to stored in DB if the Session State is set to be outproc on a SQl Server.. So how can you serialize objects on the fly when its is not marked as [Serializable]. Commented Jan 11, 2011 at 4:58

2 Answers 2

1

If it's saving to disk in any manner, it is serializing the state in some manner. You can easily serialize with XML to the database on your own.

Check out the System.Xml.Serialization namespace.

Sign up to request clarification or add additional context in comments.

Comments

0

To serialize an object means to take the information from that object and store it to some form of permanent store in a standard way so that the object can later be effectively reconstructed via that information. Any object which is going to be written out to a database should be serializable. If it is being stored without some form of serialization process, then when deserialization is attempted the object may possibly be read back in a strange or inconsistent state.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.