user3181034
user3181034

Reputation: 179

external dll visual studio C# error

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

Upvotes: 0

Views: 1593

Answers (2)

Spell
Spell

Reputation: 384

-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.

Upvotes: 0

S_Lord
S_Lord

Reputation: 54

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.

Upvotes: 0

Related Questions