1

I've encountered a problem where a small number of data objects stored using a BinaryFormatter are coming back with parameters missing (null/default).

I'd like to know if the missing items were saved as null, or if the objects that were serialized were changed from the versions in source control and then reverted before a code commit (eg int numDogs vs unsigned int dogCount).

The former would represent a serious bug in the data validation code ran before the serialization was done; while the latter is just junk data in a test DB and ignorable.

Since the BinaryFormatter is able to get everything else out when a member is changed, added, or removed I assume it's writing objects in a form similar to a key value store. Is there any way to get a human readable representation of it, without having to try and guess the exact details of the object that was serialized?

1 Answer 1

2

If you implement ISerializable on your objects, you can have a look at what's been serialized by trying to deserialize.

You will need to add a constructor with the same signature as ISerializable.GetObjectData - this is where deserialization occurs.

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

2 Comments

The example code in MSDN is for doing non-standard behavior. This site has an example of a conventional implementation: w3mentor.com/learn/asp-dot-net-c-sharp/c-streams/…
the original link in my comment's dead, but it was archived on the Wayback Machine: web.archive.org/web/20170622134922/http://w3mentor.com/learn/…

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.