I have an object that I'm serializing and storing in an MSSQL database as a varbinary.
When I retieve the varbinary and try to deserialize it, I'm having problems. I believe its something to do with the length of the byte array as the length is different going into the database and coming out.
I've tried to force the length of the array in both input and output, but that gives me an "End of Stream encountered before parsing was completed." error.
Without that, sometimes the deserialization just decides to say that it can't convert a byte to the object, and sometimes it gives a different error altogether which I can't replicate at the moment because its stopped working again LOL.
MemoryStream ms = new MemoryStream();
BinaryFormatter b=new BinaryFormatter();
SqlHelp.ExecuteSp("user_InsertSaveSearchObject", saveName, UserSessionManager.UserSession.IsDating(), UserSessionManager.UserSession.MemberID, WhereClause, ms.GetBuffer());
BinaryFormatter b = new BinaryFormatter();
MemoryStream ms = new MemoryStream((Byte)sr.dataSet.Tables.Rows["searchObject"]);
UserSessionManager.UserSession.theMemberSearch = new MemberSearch();
UserSessionManager.UserSession.theMemberSearch = (MemberSearch)b.Deserialize(ms);