我有以下方法来生成对象的哈希。它工作得很好!但是当我更改程序集的版本时,即使对象相同,哈希也会发生变化。
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));
}
怎么可能忽略汇编版本?