简体   繁体   English

DllImport拒绝找到我的本机.dll。 引发DllNotFoundException

[英]DllImport is refusing to find my native .dll. Throws DllNotFoundException

I have a project that references a native dll. 我有一个引用本机dll的项目。 I added the .dll to the project and set it to 'copy if newer' so it shows up in the output directory. 我将.dll添加到项目中,并将其设置为“如果较新则复制”,以便它显示在输出目录中。 Still every time I try to call an exported function it throws the not found error. 仍然每次我尝试调用导出的函数时,它都会引发未找到的错误。

I did a little research and read that maybe the .dll couldn't find it's dependencies. 我做了一些研究,读到.dll可能找不到它的依赖项。 I used dependency walker to check and the only dependencies listed are are Kernel32.dll and MSCVR80.DLL. 我使用了依赖项遍历程序来检查,列出的唯一依赖项是Kernel32.dll和MSCVR80.DLL。 Both of those were found on my system. 这些都在我的系统上找到。

I used dumpbin.exe and viewed all the exported functions so it does seem to be a properly formatted .dll. 我使用dumpbin.exe并查看了所有导出的函数,因此它似乎是正确格式化的.dll。 I can't figure out why DllImport can't find it. 我不知道为什么DllImport无法找到它。

I also put the DLL in a different directory and added it to my path. 我还将DLL放在另一个目录中,并将其添加到我的路径中。 That didn't help either. 那也没有帮助。 Anyone have any ideas? 有人有想法么? Anything else I can try? 我还能尝试什么吗?

Use Process monitor from Sysinternals tools ( http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx ) to look at what is accessed. 使用Sysinternals工具( http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx )中的Process Monitor来查看访问了什么。 Filter only by the process (otherwise you will get too much data) and see what requests actually failed. 仅按流程过滤(否则您将获得过多的数据),并查看实际失败的请求。 This should give you an idea what to look for. 这应该使您知道要寻找什么。

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

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