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

问题描述 投票:1回答:2

我正在使用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)

我在网上搜索了解决方案,到目前为止,以下所有内容都没有对我有用:

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

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

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

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

为了配置我的应用程序,我需要做什么才能从app文件夹访问库而不是在GAC中查找它们?

asp.net dll publish visual-studio-2015
2个回答
3
投票

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

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

C:\ Users \ User Name \ 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项目制作相同的应用程序后,我注意到这一点,并且忘记在新项目中复制外部库,这导致了开发中的相同错误(我以前没有得到过)。


0
投票

启动后在useLegacyV2RuntimeActivationPolicy="true"上添加app.config

喜欢

`<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>`

并将外部\ ffmpeg \ bin中的AForge外部DLL复制到项目bin \ debug文件夹。

© www.soinside.com 2019 - 2024. All rights reserved.