Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
外部dll visual studio C#错误_C#_Visual Studio_Dll - Fatal编程技术网

外部dll visual studio C#错误

外部dll visual studio C#错误,c#,visual-studio,dll,C#,Visual Studio,Dll,我正在使用外部dll,但我得到了这个错误 AcrCloudExtrest.exe中发生类型为“System.DllNotFoundException”的未处理异常。 其他信息:无法加载DLL“acrcloud\u extr\u windows\u 1.0.1.DLL”:找不到指定的模块。(来自HRESULT的异常:0x8007007E) 我已经将dll放在了项目文件夹中,也放在了system32和sysWOW64中,但没有任何效果 我在这里调用dll: class ACRCloudExtr {

我正在使用外部dll,但我得到了这个错误

AcrCloudExtrest.exe中发生类型为“System.DllNotFoundException”的未处理异常。 其他信息:无法加载DLL“acrcloud\u extr\u windows\u 1.0.1.DLL”:找不到指定的模块。(来自HRESULT的异常:0x8007007E)

我已经将dll放在了项目文件夹中,也放在了system32和sysWOW64中,但没有任何效果

我在这里调用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);
}
类ACRCloudExtr
{
公共静态字节[]CreateFingerprint(字节[]pcmBuffer)
{
字节[]fpBuffer=null;
if(pcmBuffer==null | | pcmBuffer.Length 0)
{
fpBuffer=新字节[fpBufferLen];
封送处理副本(pFpBuffer,fpBuffer,0,fpBufferLen);
自由指纹(pFpBuffer);
}
返回缓冲区;
}
[DllImport(“acrcloud\u extr\u windows\u 1.0.1.dll”)]
专用静态外部int create_指纹(字节[]pcm_缓冲区、int pcm_缓冲区、ref IntPtr fps_缓冲区);
[DllImport(“acrcloud\u extr\u windows\u 1.0.1.dll”)]
私有静态外部无无效\u指纹(IntPtr fps\u缓冲区);
}

如果项目的引用中有该dll,请右键单击它->属性>复制本地->设置为

否则,如果该dll作为dll文件位于项目文件夹中,请将其添加到项目中,右键单击->属性>复制到输出目录->设置为始终复制

构建您的项目。

-使用检查您的DLL以查看它调用的其他DLL


-将这些DLL复制到项目输出文件夹中。它们可能有自己的依赖项需要解决。

acrcloud\u extr\u windows\u 1.0.1.dll是否与AcrCloudExtrest.exe位于同一文件夹中?它不会告诉您找不到哪个dll,只是无法加载此dll。如果您不知道此DLL还需要什么,请使用电话或SysInternals的进程监视器。是的,如果在release配置中尝试调试bin/release,请尝试将其放入bin/debug目录。仍然不工作,我认为@HansPassant是对的,不加载在P/Invoke
[DllImport]
位于项目的程序集引用列表中…(存在混合的非托管/托管DLL,但它们并不常见。)