C# Windows 窗体 无法在 Windows10 上加载非托管C++ DLL
C# Windows Forms Unable to load unmanaged C++ DLL on Windows10
我有一个使用无人 c++ dll 的 C# Windows 窗体应用程序。当我调试或独立运行它(在 windows7 上)时,我只需将 dll 放在应用程序 exe 旁边,它运行良好。
当我尝试在 Windows10(独立运行)上执行相同的操作时,我收到以下异常:
Unable to load DLL 'AnalyzerLib.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
谁能告诉我为什么?我应该在某个地方授予权限还是注册它?
以下是我从代码访问 dll 的方法:
namespace Analyzer {
public unsafe class Connector {
[DllImport("AnalyzerLib.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
public static extern bool isAvailable();
[DllImport("AnalyzerLib.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
public static extern void win32set_DetectParams(float[] parameters, int prob_Size);
[DllImport("AnalyzerLib.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
public static extern void win32setDetectParamsAndColorMatrix(float[] parameters, int prob_Size, float[] colorMatrix16bytes);
[DllImport("AnalyzerLib.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
public static extern void win32analyzeBuffer(byte[] javaBuffer, byte[] javaInputCopyBuffer, int[] analyzeBufferResArr, int width, int height, bool convertYUV2RGB);
[DllImport("AnalyzerLib.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
public static extern int getCoreLogBufferSize();
[DllImport("AnalyzerLib.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
private static extern byte* getCoreLogBuffer();
}
}
如果要加载的 DLL 与可执行文件位于同一目录中,则会找到它。这使我们得出结论,找不到的模块是DLL的依赖项。
通常,这意味着您需要安装 DLL 所依赖的相应 MSVC 运行时。
- 确保运行的是发布版本而不是调试
-
您可以通过从命令提示符运行来找出 dll 依赖项:
垃圾箱/家属我的.dll
相关文章:
- Python ctypes:不会按预期加载 dll
- 在 Linux 平台的 C++ 中动态加载 DLL
- 为什么 LoadLibrary 失败,而 LoadLibraryA 成功加载 DLL?
- 为什么有些延迟加载 DLL 会立即使用 FFMPEG 卸载?
- 了解加载库无法加载 DLL 的原因
- 应用程序仅在qt调试器中加载dll,而不是独立加载
- dll 生成成功,但在加载 dll 时执行错误
- QT 加载.dll不调用解析
- 通过重新加载DLL,避免使用DLL预加载漏洞,任何更好的方法
- 问题在具有依赖性时从其他路径上加载DLL的DLL
- C++插件不能延迟加载dll时
- Java加载DLL,该DLL从JNI中的另一个DLL导出方法
- C++ 动态加载 DLL 错误
- GHCi 无法在 Windows 上加载.dll lib(C++ lib)
- 使用C++应用程序加载 DLL
- System.DllNotFoundException:无法使用 dotnet core 加载 DLL
- 当应用程序在不同系统上运行时,无法加载DLL异常
- 如何停止二级IMPLICITLY加载DLL的DLL劫持
- 无法加载dll libglorycolx2010.dll.该应用程序未能启动,因为其并排配置不正确.Hresult:0x
- 如何在Acrobat JavaScript中加载DLL文件