Question

I use Json.NET for serialization and deserialization purposes, with TypeNameHandling set to TypeNameHandling.All. This writes the type and assembly to the json file, e.g. "$type":"Testing.Utils.Entry, TestAssembly".

However, these names are changed when we protect the executable, which is changed everytime we protect it. So, I would like to make Json.NET automatically resolve the Testing.Utils.Entry, TestAssembly to what it is at runtime. This name could change entirely, also to 'ABC.DEF' instead of 'ABC.DEF.GHI' for example.

Because I want the entries to be saved consistently, the 'ABC.DEF' type at runtime should always be stored to Testing.Utils.Entry.

Was it helpful?

Solution

For future references, I managed to resolve this using a SerializationBinder with the BindToName and BindToType functions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top