I’m seeing a different behavior when I’m checking subclasses (Abstract->deriv) for type when I use the “base” type that is referenced in the checker program compared to when I explicitly load the “base” type in the checker program.
So if I do this in my main Checker program which has base type referenced (baseType) in:
- Load the derivType as Assembly.ReflectionOnlyLoadFrom(Path_to_deriv_dll)->typeToLoad
- var baseType = typeof(abstract_class) //Assembly for abstract_class is referenced in
- typeToLoad.IsSubClassOf(baseType) yields False
However if I do this:
- Load the baseType as Assembly.ReflectionOnlyLoadFrom(Path_to_base_type_dll)->baseType
- Load the derivType as Assembly.ReflectionOnlyLoadFrom(Path_to_deriv_dll)->typeToLoad
- Check typeToLoad.IsSubClassOf(baseType), it yields as True
Any thoughts are appreciated.
The reason for this in your case is that the type have different identities. When using
LoadFromthe assembly is loaded into the LoadFrom context and vs. the references which are loaded into theLoadcontext. Because the assemblies are loaded into different contexts the types in the assemblies have different identities.Here are some links with some more info on the subject
Link
Link