I have the following code , that loades all aseemblies that are refrenced by my porject and all referenced used by them
var types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(t => t.GetTypes())
.Where(t => t.IsClass && !t.IsAbstract && (typeof (MyType).IsAssignableFrom(t)));
foreach (var type in types.Where(type => typeof (MyType).IsAssignableFrom(type)))
{... do something ...}
On my dev box this works as expected , on other environment this causes an exception
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Why is that exception thrown ? is it possible to refactor my code to make it so that exception is ignored ?
Aucun commentaire:
Enregistrer un commentaire