简体   繁体   English

即使dll与可执行文件位于同一文件夹中,DllImport也找不到dll

[英]DllImport can't find dll even though dll is in same folder as executable

I'm trying to use the llvm-fs project, which provides llvm bindings for F#. 我正在尝试使用llvm-fs项目,该项目为F#提供llvm绑定。 I have compiled the LLVM-3.1.dll file with --enable-shared and it now resides in same directory as my compiled executable (I checked with Environment.CurrentDirectory ). 我已经使用--enable-shared编译了LLVM-3.1.dll文件,它现在与我编译的可执行文件位于同一目录中(我使用Environment.CurrentDirectory检查)。 The DllImport in llvm-fs looks like: llvm-fs中的DllImport看起来像:

[<DllImport(
    "LLVM-3.1.dll",
    EntryPoint="LLVMModuleCreateWithName",
    CallingConvention=CallingConvention.Cdecl,
    CharSet=CharSet.Ansi)>]
extern void* (* LLVMModuleRef *) moduleCreateWithNameNative(string ModuleID)

Yet when I run my application it errors with: 然而,当我运行我的应用程序时,它出错:

Unable to load DLL 'LLVM-3.1.dll': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)

How do I get the DLL to be loaded? 如何加载DLL? For reference, here's the exact DLL I'm trying to load . 作为参考, 这是我正在尝试加载的确切DLL

This: 这个:

"The specified module could not be found" “指定的模块无法找到”

can point to some library, which LLVM-3.1.dll depends from, not the LLVM-3.1.dll itself. 可以指向LLVM-3.1.dll依赖的某个库,而不是LLVM-3.1.dll本身。

当DLL或EXE无法加载时, Depends.exe非常方便 - 它显示完整的EXE / DLL依赖树,突出显示无法加载或丢失的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM