Reputation: 6903
I have a app with plugins, which are loaded dynamically. I keep types from those assemblies in an array of Type objects. Then, when app is closing, it saves this array into a file by serialization. When app is starting It load this file and try to deserialize It an error occurs because assemblies containing classes described in those types, are unavailable. I can't understand why It happens: a type 'Type' is in a mscorlib or something like this. Does object type has reference to type which It describe?
Upvotes: 0
Views: 86
Reputation: 1502276
Consider the Assembly
property of the type Type
. That returns a reference to the assembly containing the type. In order to get that reference, the assembly has to be loaded (possibly "for reflection only"). Likewise you can ask a type for all its methods, etc - how would you expect that to work without the assembly being present?
I suppose a Type
could be serialized in such a way that all the property values are only populated as and when they're required, so you could have a Type
object which referred to a type in a missing assembly... but it would be pretty odd.
Perhaps you should just keep hold of the fully-qualified type name instead of the Type
itself, if that's all you want to be able to rely on?
Upvotes: 1