code_junkie

How do I maintain deserialization compatibility across obfuscated and debug builds

Nov 14th, 2011
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. //to avoid cross-versioning problems
  2. public sealed class CrossVersionDeserializationBinder : SerializationBinder {
  3. public override Type BindToType(string assemblyName, string typeName) {
  4. Type typeToDeserialize = null;
  5.  
  6. typeToDeserialize = Type.GetType(String.Format("{0}, {1}",
  7. typeName, assemblyName));
  8.  
  9. return typeToDeserialize;
  10. }
  11. }
  12.  
  13. [ProtoContract]
  14. public class Foo {
  15. [ProtoMember(1)]
  16. public string Bar {get;set;}
  17. }
  18.  
  19. [ProtoContract]
  20. public class a12 {
  21. [ProtoMember(1)]
  22. public string a {get;set;}
  23. }
  24.  
  25. [DataContract]
  26. public class a12 {
  27. [DataMember(Name="Bar")]
  28. public string a {get;set;}
  29. }
Add Comment
Please, Sign In to add comment