Hi,
We've come up with a strategy to handle backward compatibility when there is a breaking change between two versions. We load the previous version assemblies in the current AppDomain, deserialize some data with the old version types and then convert these into their equivalent in the new version.
- Are there any pitfalls with this approach that I should be aware of?
- What would happen if I try to load a type by reflection when its assembly version is omitted, will it always load the latest version of the type if two version of it exists in the current AppDomain?
Edit:
Here is an scenario of question #2,
These two assemblies are loaded in the same AppDomain:
MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
MyAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
Both assembly define the type MyAssembly.MyType
.
Then if some code use this kind of reflection:
Type t = Type.GetType("MyAssembly.MyType, MyAssembly, Culture=neutral, PublicKeyToken=b17a5c561934e089");
Will this call deterministically return MyAssembly.MyType, MyAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
?
I guess the same scenario would occur if I use BinaryFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple
when deserializing types that exists in two loaded version of the same assembly.