Short version: I'm trying to customize serialization across an AppDomain boundry, specifically to handle cases where each side of the AppDomain has a slightly different version of the class. How do I do this?
Long version: We're using AppDomains to manage different submodules underneath the larger application. We want to deploy these submodules independently, hence the use of AppDomains. We have a shared contracts dll between the main application and the submodules, different versions of the contracts dll can end up in the various submodules as each one gets updated less frequently than the main application. As a result, sometimes a new field or new type gets added in the contracts dll, and is used in the main application, but the submodule does not know how to serialize it.
I think I can fix this issue by customizing the serialization process, specifically SerializationBinder.BindToType. However to do this, I need to tell each side of the AppDomain to use this serialization binder. How do I do this? All of the examples I've seen online have explicit calls to Serialize() and Deserialize(). My code for initializing the AppDomain is:
var appDomainSetup = new AppDomainSetup
{
ApplicationBase = config.BasePath,
ShadowCopyFiles = "true",
ConfigurationFile = File.Exists(configPath) ? configPath : null,
};
AppDomain.CreateDomain("myappdomain", null, appDomainSetup);
Thanks for the assistance on this.