Deserialization of optional fields from BinaryFormatter
问题 I have an application that serializes data using BinaryFormatter . A member was added to the class that was serialized from one version to the next without changing the class name. Code was added to handle the possible absence of the added member in old serialized files: private void readData(FileStream fs, SymmetricAlgorithm dataKey) { CryptoStream cs = null; try { cs = new CryptoStream(fs, dataKey.CreateDecryptor(), CryptoStreamMode.Read); BinaryFormatter bf = new BinaryFormatter(); string