zlibwapi.dll
和zlibwapi64.dll
。这些dll文件已经复制到我的应用程序文件夹,并且被引用如下:
[DllImport(@"zlibwapi.dll", EntryPoint = "uncompress", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = false)]
private static extern int uncompress32(
IntPtr dest,
ref uint destLen,
[In(), MarshalAs(UnmanagedType.LPArray)] byte[] source,
uint sourceLen
);
[DllImport(@"zlibwapi64.dll", EntryPoint = "uncompress", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = false)]
private static extern int uncompress64(
IntPtr dest,
ref uint destLen,
[In(), MarshalAs(UnmanagedType.LPArray)] byte[] source,
uint sourceLen
);
在运行时,我会检查自己是32位还是64位,并调用相应的版本。
如果我是32位,则这个方法可以正常工作,但64位版本会出现以下错误:
无法加载DLL“zlibwapi64.dll”:找不到模块。(HRESULT异常:0x8007007E)
我在互联网上找到了许多类似的问题,并且建议的原因是该库依赖于其他一些库,而可能找不到这些库。
但事实并非如此:
- zlibwapi64.dll仅依赖于Kernel32.dll和MSVCR90.dll。我已经安装了VS2008 C++运行时库,包括32位和64位。
- 当我尝试从非托管的C++应用程序中加载zlibwapi64.dll时,它可以顺利加载。只有使用C#时它才无法加载。
我尝试将64位dll的绝对路径设置为加载路径,但没有帮助。
我该如何使其工作?
uncompress32
而不尝试调用uncompress64
。当我将项目设置为x64时,它不会尝试调用uncompress32
并且无法调用uncompress64
。 - GSerg