How to change the loading path of references in .NET?

前端 未结 3 1131
逝去的感伤
逝去的感伤 2021-01-16 07:20

I want a setup like this:

+- /ApplicationFolder
  -- App.exe
  -- Core.dll
  -- AnotherShared.dll
  +- /PluginsFolder
    -- plugin1.dll
    -- plugin2.dll
<         


        
3条回答
  •  醉梦人生
    2021-01-16 07:25

    you can try this: How can I set PrivateBinPath in MEF?

    or you can try handling the Appdomain.AssemblyResolve event that is raised anytime .net cant locate an assembly. there you can implement custom logic to locate and load assemblies from anywhere.

    the AssemblyResolve eventhandler jsut returns either the assembly that is beeing looked for or null, so you could return the already loaded Core.dll from available from the AppDomain.GetAssemblies() method.

    however in your case it should be ok to simply not include Code.dll with plugin1.dll, .net should already realize that Core.dll is loaded and use that instance

提交回复
热议问题