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

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

问题描述

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

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.

I .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.

不同的插件可能具有相同的库,因此我想收集这些库.p旁边的依赖项。

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天全站免登陆