手动设置装配参考

Set manully assembly reference

我有这个结构

--Loader.exe
--Core.dll
--Plugins/Test.dll

--C:\Program Files\Program\Program.exe

程序集 Test.dll 引用了 Core.dll,这很好。当我 运行 Loader.exe 时,它会将 Core.dll 注入到另一个进程 (Program.exe) 中,当它这样做时,它会尝试加载程序集 Test.dll。问题是 Test.dll 正在路径 C:\Program Files\Program\ instad 中查找引用 Core.dll 加载路径。

解决方案:(我正在搜索)

我只是在寻找如何从执行路径而不是另一个进程路径加载引用的方法。

问题:

不明白 Core.dll 是否加载引用了 Core.dll 的程序集,为什么它不能从自身加载?

加载引用程序集的目录由 AppDomain 的配置决定,您的代码在 运行 中,具体来说,例如 AppDomain.BaseDirectory and AppDomain.RelativeSearchPath properties. By default, the assemblies are loaded from the directory which contains your entry point assembly (usually your main EXE application assembly). To customize these paths you need to create a custom AppDomain. Alternatively, you can load the assemblies manually, using Assembly.LoadFile or Assembly.LoadFrom