I use AutoFac to automatically register dependencies based on their interface implementations as follows:
builder.RegisterAssemblyTypes(Assembly.GetEntryAssembly()).AsImplementedInterfaces();
This is great for input assembly, but what about all related assemblies?
I would like to do something like:
IList<Assembly> assemblies = GetLoadedAssemblies();
foreach(var assembly in assemblies)
{
builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();
}
I searched and saw a bunch of .netcore 1.0 using AssemblyLoadContext, etc., but this no longer looks like 1.1. Basically, when you search, you get a lot of outdated links to things that no longer work.
There should be a way to get currently loaded assemblies.
How can i do this?
source
share