Dynamically load a DLL from a specific folder?

后端 未结 5 744

At the moment, I have this code :

var shellViewLibrary = Assembly.LoadFrom(Path.Combine(_DllsPath, _DllShellView));
IEnumerable types = shellView         


        
5条回答
  •  有刺的猬
    2021-01-13 18:32

    I'm not sure what you mean by this:

    create an object whose type is type in a specific folder (that is outside the build folder)

    A type only exists in an assembly. Path is entirely irrelevant to types in .NET

    I assume that by "path" you really mean "namespace", meaning that you don't know in which namespace the type exists. You have already loaded the assembly in your code. Inspect the assembly using reflection to find the type you're looking for. Then pass the Type object that represents the type you're looking for to Activator.CreateInstance

提交回复
热议问题