0

I have a C# Windows Forms Application that use an unmanned c++ dll. 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.

When I try to do the same on Windows10 (run as standalone) I get the following exception:

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:

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();

        }
}
Asaf Pinhassi
  • 15,177
  • 12
  • 106
  • 130
  • Please check if this is not related: http://stackoverflow.com/questions/9003072/unable-to-load-dll-module-could-not-be-found-hresult-0x8007007e – Kuba Wyrostek Jan 28 '16 at 09:12

1 Answers1

0

If the DLL you are loading is in the same directory as the executable, then it will be found. Which leads us to conclude that the module(s) that cannot be found are your DLL's dependencies.

Normally this means that you need to install the appropriate MSVC runtime upon which your DLL depends.

  • Make sure the you run the release version and not the debug
  • You can figure out the dll dependencies by running from command prompted:

    dumpbin /DEPENDENTS my.dll

Asaf Pinhassi
  • 15,177
  • 12
  • 106
  • 130
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490