我正在我的 VB .Net 程序中添加 VC++ 库,例如使用:
<DllImport("KMpeg4.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Shared Function KOpenInterface() As System.IntPtr
End Function
我在运行时遇到错误:
Unable to load DLL 'KMpeg4.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
我已经把这个库放在任何地方了,包括system32
,仍然没有运气,这意味着它缺少KMpeg4.dll
的依赖库。
所以我运行了 Dependency walker,它给了我缺少的库:
API-MS-WIN-CORE-COM-L1-1-0.DLL API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL API-MS-WIN-CORE-WINRT-L1-1-0.DLL API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL API-MS-WIN-SHCORE-SCALING-L1-1-0.DLL DCOMP.DLL GPSVC.DLL IESHIMS.DLL
以及糟糕的链接功能:
c:\windows\system32\API-MS-WIN-CORE-THREADPOOL-L1-1-0.DLL c:\windows\system32\OLE32.DLL c:\windows\system32\DWMAPI.DLL c:\windows\system32\IEFRAME.DLL c:\windows\system32\IMM32.DLL c:\windows\system32\MFPLAT.DLL c:\windows\system32\NDFAPI.DLL c:\windows\system32\USERENV.DLL c:\windows\system32\UXTHEME.DLL
依赖遍历器给出以下错误:
Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
我已经安装了 Microsoft VC++ 2005,2008,2010 x86 和 x64 以及 .Net Framework 4。
我还尝试使用 sysinternal 进程监视器查看 KMpeg4.dll
弹出窗口,但在程序出现错误异常之前它不会加载 KMpeg4.dll
有什么想法这些库可能来自哪个包吗?
或者,如何解决这个问题?
最佳答案
Dependency Walker 对于诊断此问题没有用处,这样的 DLL 仅在运行时才能找到。复制到 system32 通常是大锤解决方案。除非在 64 位版本的 Windows 上,项目的平台目标设置为 x86,在这种情况下很可能,因为这肯定是一个 32 位 DLL,然后您需要将其敲入 c:\windows\syswow64。
但不要这样做,您只需确保 DLL 与项目的 EXE 位于同一目录中即可。最好的方法是:
- 右键单击您的 EXE 项目,添加 + 现有项目
- 导航到您的 KMpeg4.dll 拷贝并选择它
- 选择添加的项目,将“复制到输出目录”属性设置为“如果较新则复制”
重建后,您现在将在正确的位置拥有 DLL 的拷贝。不要忘记将其与项目的可执行文件一起部署,也不要忘记用户计算机上可能需要的运行时支持 DLL。
关于c++ - VB.NET 无法加载 DLL 找不到指定的模块。当dll导入时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19030099/