samedi 6 juillet 2019

.NET Core 2.x Load Referenced Assemblies, that have no type references in code

I have a .NET Core 2.2 project A, that has package references to assemblies B and C. (basically NuGet referenced dlls)

I need to have B and C loaded dynamically at runtime, however I cant seem to find any documentation on how I might achieve this.

A lot of posts refer to calling Assembly.Load() on all referenced assemblies via Assembly.GetExecutingAssembly().GetReferencedAssemblies(), however this only retrieves assemblies, that have some of their types explicitly referenced inside the executing assembly's code

This does not work for me, as I dont have any refernces to their types in my code.

I found that you could get a full list of referenced assemblies, via doing a Assembly.ReflectionOnlyLoad(), however this is not supported with the .NET Core Runtime.

I tried searching through the AppDomain and AssemblyLoadContext classes, in order to find such information, but could not find anything useful.

So summarized, my question is how can I dynamically load an assembly's referenced assemblies without explicitly touching some of their types in my code?





Aucun commentaire:

Enregistrer un commentaire