Assembly.LoadFrom 和依赖项 [英] Assembly.LoadFrom and dependencies

查看:42
本文介绍了Assembly.LoadFrom 和依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 Assembly.LoadFrom() 设置插件系统,该系统会在 .exe 目录的子文件夹中动态加载 dll.

I've been trying to setup a plugin system using Assembly.LoadFrom() that dynamically loads dlls in a sub-folder of the .exe's directory.

我有一个由 .exe 和插件引用的接口库.构建完成后,我将插件 dll 复制到子文件夹中.

I have one interface lib referenced by both the .exe and the plugin. Once the build is done i copy the plugin dll to the sub-folder.

不同的插件可能有共同的库,所以我想在 .exe 旁边收集这些依赖项.

Differents plugins might have libs in common, so i would like to gather those dependencies next to the .exe.

我的理解是我必须使用 AssemblyResolve 事件从 exe 目录手动加载插件依赖项.这样对吗 ?因为它看起来很笨拙.

My understanding is that i have to use the AssemblyResolve event to manually load plugins dependencies from the exe's directory. Is this correct ? Because it seems very cumberstone.

推荐答案

使用 ProcMon.exe 解决.丢失的 dll 实际上已正确加载.但它也有我没有复制到 exe 文件夹的依赖项.DllNotFoundException 的消息令人困惑,因为它没有报告丢失的 dll,而是报告了失败的 dll.

Solved by using ProcMon.exe. The missing dll was in fact correctly loaded. But it also had dependencies that i didn't copy to the exe folder. The DllNotFoundException had as confusing message as it didn't report the missing dll but rather the failing dll.

这篇关于Assembly.LoadFrom 和依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆