c# - Dynamically create an instance of a type from an assembly that is already referenced (but never accessed) -
using .net core console app
i have assembly runner.exe
has reference functions.dll
. inside functions.dll
there's class called functions.mylibary
from runner.exe
want create instance of functions.mylibary
(using qualified string name)
i've tried how dynamically load assemblies in dotnet core. unfortunately works if assembly functions.dll
not referenced.
assembly.getentryassembly().getreferencedassemblies()
doesn't contain informations functions.dll
. (if don't use classes functions.dll
)
any clue how solve issue?
in runner.exe
static void main(string[] args) { // functions.dll not there.. unless next line gets uncommented var assemblies = assembly.getentryassembly().getreferencedassemblies(); //var dummy = new functions.mylibrary(); // works assembly not referenced. var = system.runtime.loader.assemblyloadcontext .default.loadfromassemblypath(@"path\functions.dll"); }
in functions.dll
public class mylibrary { public void foo() { } }
Comments
Post a Comment