Consider the following scenario:
- In the Microsoft .NET Framework 2.0 Service Pack 2 (SP2) or in the Microsoft .NET Framework 3.5 Service Pack 1 (SP1), you use the BinaryFormatter object to serialize and to deserialize a generic type in an assembly.
- The assembly is shared between the server and the client, and the assembly has a strong name.
- The build versions of the assembly are different between the server and the client.
Error message 1
System.Runtime.Serialization.SerializationException: Unable to find assembly.
Error message 2
System.IO.FileLoadException: Could not load file or assembly 'Common, Version=version ID, Culture=neutral, PublicKeyToken=key number or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) If you have registered the assembly in the GAC, you receive the following exception: System.InvalidCastException: Return argument has an invalid type.
Notes- This problem does not occur when you use the SoapFormatter object.
- This problem occurs even if you set the FormatterAssemblyStyle.Simple value when you serialize and deserialize.