2016-01-28 73 views
0

我有一個C#Windows窗體使用無人C++ DLL中的應用。 當我調試,或運行它作爲獨立的(上windows7的),我只是把旁邊的應用程序的EXE和DLL運行偉大。C#Windows窗體無法加載非託管C++ DLL在Windows10

當我試圖做同樣的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(); 

     } 
} 
+0

請檢查是否這是不相關:http://stackoverflow.com/questions/9003072/unable-to-load-dll-module-could-not-be-found-hresult-0x8007007e –

回答

0

如果您加載的DLL是在同一目錄下的可執行文件,那麼它會被發現。這導致我們得出結論:無法找到的模塊是您DLL的依賴關係。

通常,這意味着你需要安裝在其上的DLL取決於適當的MSVC運行。

  • 確保您運行發行版本,而不是調試
  • 您可以通過命令運行弄清楚DLL依賴提示:

    DUMPBIN/DEPENDENTS my.dll