mercredi 14 novembre 2018

Type loading by Assembly.LoadFrom is not the same

I'm creating type by name to put them to DI container. For any reason the DI container fails to register/resolve types created this way:

Type interfaceTypeFromAssembly = Assembly.LoadFrom(InterfacesAssemblyPath).GetTypes().First(t => t.Name == interfaceName);
Type implementorTypeFromAssembly = Assembly.LoadFrom(ApplicationAssemblyPath).GetTypes().First(t => t.Name == implementorClassName);

I compared types and found that:

Type implClassType= typeof(ImplClass);
Type implClassType2= typeof(ImplClass);
bool res = implClassType == implClassType2; // True

res = implClassType == implementorTypeFromAssembly; // False

The last line gives False although types have the same GUID.

What's the reason of such a behavior?





Aucun commentaire:

Enregistrer un commentaire