So, attempting to walk types looking for those classes with an interface.
Methods:
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach(...)
var types=assembly.GetTypes();
Exception:
{“Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.”}
Content of LoaderExceptions:
{“Method ‘Do’ in type ‘namespaceinfo.ImportR’ from assembly ‘namespaceInfo.Importer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’ does not have an implementation.”:”nameSpaceInfo.ImportR”}
Info discovered so far on SO —
-
.Net loads in types / assemblies on demand. Perhaps a dependency hasn’t been loaded yet.
-
… that’s about it for now.
After spending several hours on this, I’m starting to think that decorating classes with attributes and then walking them afterwards for certain reasons could be a bad idea in some situations. Clearly other services do this successfully. What am I missing? Is there a smart implementation in something like Fluent that I should take a look at?
The answer so far is do not walk the types in one particular assembly. ie. filter it out
It seems like you are trying to load implementations of a specific interface at runtime. Presumably to create instances and use them within your application. If so then instead of hand rolling this I would suggest using a framework like MEF which is designed to do exactly this.