I'm dynamically loading an assembly using Assembly.LoadFrom()
, then instantiating some of its types using .CreateInstance()
. Next, I put these objects into an array and serialize it to a file using json.net (configured with TypeNameHandling.Auto
). In the file I can see that it is storing the correct type names, e.g.:-
"Features": [{
"$type": "FeaturesAssembly.SomeFeature, FeaturesAssembly",
// Other serialized properties
}]
The problem is that I can't deserialize the file. Json.net throws a JsonSerializationException, message "Could not load assembly 'FeatureAssembly'", despite the necessary assembly having been dynamically loaded first. What am I missing?