[英]C# Windows Forms Unable to load unmanaged C++ DLL on Windows10
I have a C# Windows Forms Application that use an unmanned c++ dll. 我有一个使用无人C ++ dll的C#Windows窗体应用程序。 When when I debug, or run it as standalone (on windows7), I just put the dll next to the app exe and it runs great.
当我调试或独立运行(在Windows7上)时,我只是将dll放在了应用exe旁边,因此运行效果很好。
When I try to do the same on Windows10 (run as standalone) I get the following exception: 当我尝试在Windows10上执行相同操作(独立运行)时,出现以下异常:
Unable to load DLL 'AnalyzerLib.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Can anyone tell me why? 谁能告诉我为什么? should I give a permission somewhere or register it?
我应该在某个地方授予许可还是进行注册?
Here is how I access the dll from code: 这是我从代码访问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();
}
}
If the DLL you are loading is in the same directory as the executable, then it will be found. 如果要加载的DLL与可执行文件位于同一目录中,则将找到该文件。 Which leads us to conclude that the module(s) that cannot be found are your DLL's dependencies.
这使我们得出结论,找不到的模块是您的DLL的依赖项。
Normally this means that you need to install the appropriate MSVC runtime upon which your DLL depends. 通常,这意味着您需要安装DLL所依赖的适当的MSVC运行时。
You can figure out the dll dependencies by running from command prompted: 您可以通过在命令提示符下运行来确定dll依赖项:
dumpbin /DEPENDENTS my.dll dumpbin / DEPENDENTS my.dll
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.