c# - Different behavior of IsSubClassOf for referenced type and loaded types -


After the

When I use" I have a different behavior when I'm checking subclasses (abstract> deriv) for type Type "Base" type that is visible when I explicitly refer to the checker program in comparison to the "base in the checker program" type.

So base type if I have been referring to doing this in my main tester program (baseType):

  1. Assembly.ReflectionOnlyLoadFrom form derivType (Path_to_deriv_dll) load -> TypeToLoad
  2. in the baseType = typeof (abstract_class) // assembly for abstract_class
  3. typeToLoad.IsSubClassOf (baseType) yields false

If I do this:

  1. load the derivType as assembly.ReflectionOnlyLoadFrom form the BaseType (Path_to_base_type_dll) load -> baseType
  2. Assembly.ReflectionOnlyLoadFrom (Path_to_deriv_dll) -> typeToLoad < / Li>
  3. Check typeToLoad.IsSubClassOf (baseType) True
yields

is appreciate any ideas.

The reason for this in your case is that there is a different identity of type LoadFrom Load context because the assemblies are loaded in different contexts, the types of identities in the assemblies are different.

Here are some links with some more information on this topic


Comments