0
votes

I am using external dll,but i am getting this error

An unhandled exception of type 'System.DllNotFoundException' occurred in ACRCloudExtrTest.exe. Additional information: Unable to load DLL 'acrcloud_extr_windows_1.0.1.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

i've put the dll in the project folder, also in system32 and sysWOW64 but nothing worked.

Here i am calling the dll:

class ACRCloudExtr
{
    public static byte[] CreateFingerprint(byte[] pcmBuffer)
    {
        byte[] fpBuffer = null;
        if (pcmBuffer == null || pcmBuffer.Length <= 0)
        {
            return fpBuffer;
        }
        IntPtr pFpBuffer = IntPtr.Zero;
        int fpBufferLen = create_fingerprint(pcmBuffer, pcmBuffer.Length, ref pFpBuffer);
        if (fpBufferLen > 0)
        {
            fpBuffer = new byte[fpBufferLen];
            Marshal.Copy(pFpBuffer, fpBuffer, 0, fpBufferLen);
            free_fingerprint(pFpBuffer);
        }
        return fpBuffer;
    }

    [DllImport("acrcloud_extr_windows_1.0.1.dll")]
    private static extern int create_fingerprint(byte[] pcm_buffer, int pcm_buffer_len, ref IntPtr fps_buffer);
    [DllImport("acrcloud_extr_windows_1.0.1.dll")]
    private static extern void free_fingerprint(IntPtr fps_buffer);
}
2
Is acrcloud_extr_windows_1.0.1.dll in the same folder as ACRCloudExtrTest.exe? - Polyfun
It doesn't tell you what DLL could not be found, only that this DLL could not be loaded. If you have no idea what other DLLs this one needs then use a telephone or SysInternals' Process Monitor. - Hans Passant
try putting it in the bin/debug directory if trying to debug bin/release if in release configuration. - Jason
still not working, i think @HansPassant is right, not loading - user3181034

2 Answers

0
votes

If you have that dll in references of your project right click on it -> properties -> Copy Local -> set to true.

Else if that dll is in project folder as a dll file add it to your project, right click -> properties -> Copy to Output Directory -> set to Copy Always.

Build your project.

0
votes

-Inspect your DLL using Dependency Walker to see what other DLL it calls.

-Copy those DLLs in your project output folder. They might have dependencies of their own to resolve.