BinaryFormatter ignora a versão de montagem
Eu tenho o seguinte método para gerar um hash de um objeto. Isso funciona muito bem! Mas quando eu mudo a versão da montagem, o hash está mudando mesmo quando o objeto é o mesmo.
public static string GetHash(Object item)
{
MemoryStream memoryStream = new MemoryStream();
BinaryFormatter binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(memoryStream, item);
binaryFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
HashAlgorithm hashAlgorithm = new MD5CryptoServiceProvider();
memoryStream.Seek(0, SeekOrigin.Begin);
return Convert.ToBase64String(hashAlgorithm.ComputeHash(memoryStream));
}
Como é possível ignorar a versão de montagem?