I'm currently using AssemblyLoadContext.Default.LoadFromAssemblyPath(path/to/netstandard1.6lib.dll)
and was curious about how to handle any nuget dependencies that library may have?
For example: Library A dynamically loads Library B. Library B depends on Redis from NuGet.
Library B loads correctly, but upon using the redis client -- we get a nasty FileNotFoundException complaining that the redis assembly cannot be found. The scenario is really a typical module-loader type thing.
Assembly assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path);
if (assembly == null)
throw new InvalidExtensionException(name, path);
TypeInfo type = assembly.DefinedTypes.FirstOrDefault(x => x.ImplementedInterfaces.Contains(typeof(IExtension)));
if (type == null)
throw new InvalidExtensionException(name, path);
IExtension extension = Activator.CreateInstance(type.AsType(), name, _dependencyUtility) as IExtension;
if (extension == null)
throw new InvalidExtensionException(name, path);
extensions.Add(extension);
When Activator creates the instance, the extension's constructor attempts to make a new redis client -- and it all blows up.
Any thoughts on how to handle 3rd level dependencies from nuget at runtime?