DllImport is refusing to find my native .dll. Throws DllNotFoundException

I have a project that references a native dll. I added the .dll to the project and set it to 'copy if newer' so it shows up in the output directory. 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. I used dependency walker to check and the only dependencies listed are are Kernel32.dll and 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. I can't figure out why DllImport can't find it.

I also put the DLL in a different directory and added it to my path. 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. 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.

链接地址: http://www.djcxy.com/p/44538.html

上一篇: 在asp.net中加载混合模式程序集

下一篇: DllImport拒绝找到我的本地.dll。 引发DllNotFoundException