简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM