But when I change the version of the assembly, the hash is changing even when the object is the same.
yes, that is expected behaviour when using BinaryFormatter
... it does not guarantee to create the same output - and especially since it includes full type information (including version) it is pretty much guaranteed to change between versions.
I would consider using a serializer that doesn't include type information; XmlSerializer
, Json.NET or protobuf-net would leap to mind.