无法加载文件或程序集“AForge.Video.FFMPEG.dll”或其依赖项之一

Rod*_*ala 4 asp.net dll publish visual-studio-2015

我正在使用 Visual Studio Community 2015 开发 .NET 应用程序,它使用一些 AForge.NET 库。我添加了对我的项目的引用,当我调试应用程序时,库工作正常。但是,当我发布应用程序并将其安装在同一台计算机上时,只要我到达使用 AForge.NET 库的应用程序的一部分,应用程序就会崩溃并显示以下错误:

System.IO.FileNotFoundException: Could not load file or assembly 'AForge.Video.FFMPEG.dll' or one of its dependencies. The specified module could not be found.
Filename: 'AForge.Video.FFMPEG.dll'
    on MyApp.mySecondForm..ctor(Int32 id)
    on MyApp.myMainForm.myListView_DoubleClick(Object sender, EventArgs e)
    on System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
    on System.Windows.Forms.ListView.WndProc(Message& m)
    on System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    on System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    on System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Run Code Online (Sandbox Code Playgroud)

我在网上搜索过这个问题的解决方案,到目前为止,以下没有一个对我有用:

  • 安装 Visual Studio C++ Redistributable(认为它可能缺少依赖项)
  • 使用文件系统编辑器在安装时添加库(我在 Visual Studio 中找不到编辑器)。

此外,我搜索了安装应用程序的文件夹,我看到所有 DLL 文件都在那里,每个文件都在不同的文件夹中,以及一个文件夹,其中包含其他文件中的每个 DLL。

我对其他库(全局程序集缓存中的库)没有问题,例如MySql.Data.

按照Chris O的建议,我使用 Process Monitor 检查我的应用程序,它显示它正在 GAC 中寻找 AForge 库;因为我没有在那里添加它们,所以无法找到它们。

我需要做什么来配置我的应用程序,以便它可以从应用程序文件夹访问库,而不是在 GAC 中查找它们?

Rod*_*ala 6

外部库必须复制到包含 AForge.Video 库的安装文件夹。

AForge.Video库包含一些无法添加为引用的外部 DLL 文件。相反,它们必须复制到项目的 bin 文件夹中。同样,安装应用程序后,必须将它们复制到其他 DLL 文件所在的文件夹。文件夹的确切名称各不相同,但就我而言,我必须将它们复制到以下目录:

C:\Users\用户名\AppData\Local\Apps\2.0\3V9YACJD.EPJ\V4BGBR0L.485\appe..tion_0000000000000000_0001.0008_b483b48e9712fa89

需要复制的DLL文件有:

  • avcodec-53.dll
  • avdevice-53.dll
  • avfilter-2.dll
  • avformat-53.dll
  • avutil-51.dll
  • postproc-52.dll
  • swresample-0.dll
  • swscale-2.dll

在将相同的应用程序制作为新的 Visual Studio 项目后,我注意到了这一点,并且忘记在新项目中复制外部库,这在开发中导致了相同的错误(我之前没有遇到过)。