FileNotFoundException 尝试从托管代码加载 DLL
首先,我想说我对 Windows 链接系统相当不熟悉。 (我的大部分编程经验都是在 Mac OS 上获得的,在 Mac OS 上,链接库和框架完全不同。我也不是 Windows 用户。)
这是我的设置:我在同一个解决方案中有两个项目。第一个是我们称之为 Foo
的 C++/CLI 项目。 Foo
是一个依赖于外部库(Java 运行时环境)的库项目,因此具有对适当(我相信因为它编译).lib 文件的适当引用。 (我没有更改与加载该库相关的其他项目设置。)我的另一个项目 Bar
是一个引用 Foo
的 C# 控制台可执行项目。
两者都编译得很好。
但是,当我执行 Bar.exe
C# 程序时,它在构造第一个需要 Foo
类型的对象之前就终止了。异常是 FileNotFoundException
,它指出找不到 Foo.dll
程序集或其依赖项之一。
因此,我启动了 fuslogvw
来查看出了什么问题,但我并不真正了解它是如何工作的,而且我在它上面找到的文档也毫无帮助。据我所知, Foo
和 Bar
都未能作为本机图像加载,但被发现是正确的 IL,并以这种方式正确加载。不过,没有其他相关的失败提及,显然它在某些时候确实会失败。我会发布日志,但它们是法语的,我认为这毫无用处。
有什么想法吗?
To start off, I'd like to say I'm rather unfamiliar with the Windows linking system. (Most of my programming experience was acquired on Mac OS, on which linking libraries and framework is radically different. I'm also not much of a Windows user.)
This is my setup: I've got two projects in the same solution. The first is a C++/CLI project we'll call Foo
. Foo
is a library project that depends on an external library (the Java Runtime Environment), and thus has the appropriate reference to the appropriate (I believe since it compiles) .lib file. (I changed no other project setting related to loading that library.) My other project, Bar
is a C# console executable project that references Foo
.
Both compile just fine.
However, when I execute my Bar.exe
C# program, it dies before the construction of the first object that requires types from Foo
. The exception is a FileNotFoundException
that states the Foo.dll
assembly or one of its dependencies couldn't be found.
So I launched fuslogvw
to see what went wrong, but I don't really understand how it works, and the documentation I found on it is rather unhelpful. From what I think I understand, both Foo
and Bar
failed to load as native images, but were found to be correct IL and were properly loaded that way. There is no other relevant mention of failure, though, obviously it does fail at some point. I'd post the logs, but they're in French and I think it would be pretty useless.
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有可执行文件和 dll 依赖项都在输出目录中吗?首先使用 Depends 检查本机依赖项。
Are all the executable and dll dependencies in the output directory? Check the native dependencies first with Depends.