【问题标题】:Could not load or assembly or one of its dependencies无法加载或组装或其依赖项之一
【发布时间】:2014-10-21 06:28:36
【问题描述】:

我正在使用 Aforge.net 框架进行图像处理工作。 我添加了“AForge.Video.FFMPEG.dll”作为我项目的参考。 我正在使用 VS2012 和 32 位构建目标。 建造时我得到

 System.IO.FileNotFoundException was unhandled
  HResult=-2147024770
  Message=Could not load file or assembly 'AForge.Video.FFMPEG.dll' or one of its dependencies. The specified module could not be found.
  Source=VideoReadere
  FileName=AForge.Video.FFMPEG.dll
  FusionLog=""
  StackTrace:
       at VideoReadere.Form1..ctor()
       at VideoReadere.Program.Main() in c:\Users\Prabad\Documents\Visual Studio 2012\Projects\VideoReadere\VideoReadere\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

我的代码是发生异常

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace VideoReadere
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
//here below line give exception
            Application.Run(new Form1());
        }
    }
}

【问题讨论】:

  • AForge.Video.FFMPEG.dll 是否存在于可执行路径中?
  • 你看到VS中References文件夹下AForge.Video.FFMPEG.dll旁边有一个黄色三角形吗?
  • 如果您正确添加了引用,那么我会注意这部分错误消息“或其依赖项之一”。您是否还引用了 AForge.Video.FFMPEG.dll 所依赖的所有 DLL。
  • 我如何找到 AForge.Video.FFMPEG.dll 的依赖关系
  • 使用 Dependancy Walker from 查找您的依赖项。你可以从dependencywalker.com下载

标签: c# ffmpeg filenotfoundexception aforge


【解决方案1】:

您需要将 DLL 从“Externals\ffmpeg\bin”复制到 AForge.Video.FFMPEG.dll 位置,并且可能需要安装 Microsoft Visual C++ Redistributable。

【讨论】:

  • 还需要替换app.config中的如下标签
  • 短语“找不到指定的模块。”意味着(在你的情况下)你需要安装 C++ 可再发行包。
【解决方案2】:

我知道这有点晚了,但我希望我的回答对某人有所帮助。 我遇到了这个问题,这给了我一些困难。 这对我来说是这样的:

  1. 项目 -> 添加现有项目(如其他答案中所述,从“Externals\ffmpeg\bin”浏览至 DLL)
  2. 确保显示文件类型下拉列表中的所有类型
  3. 选择所有 DLL,然后从添加按钮中选择添加链接选项
  4. DLL 应该显示在您的项目解决方案中,选择所有这些
  5. 编辑 Build Action 属性并将其设为 NativeBinary
  6. 编辑复制到输出目录并使其始终复制

就是这样。这对我有用,我发布了我的应用程序,它在 Windows 平板电脑上工作。 干杯

【讨论】:

  • 我在第 5 步中没有找到 NativeBinary 选项。
【解决方案3】:

试试这个

检查项目目标是 x86,因为该程序集在 64 中无法工作。然后检查 FFMPEG dll 是否在您的应用程序的同一目录中。

【讨论】:

    【解决方案4】:

    试试这个工具:Dependency Walker 它节省了我几次时间。

    编辑: 抱歉,我看到最后一条评论太晚了。

    【讨论】:

      【解决方案5】:

      我通过在发布模式下重建项目解决了这个问题(我使用 Visual Studio 2013)

      【讨论】:

        【解决方案6】:

        我尝试了所有推荐的解决方案,但没有一个对我有用,当我使用 dependencywalker 时,我注意到库缺少文件(版本 2.2.5)。所以我下载了以前的 2.2.4 版本,它对我来说很好用。

        【讨论】:

          【解决方案7】:

          为了修复这个错误,我将目标 CPU 更改为 X86 以匹配所引用的 Chilkat-dll 组件的架构。对于其他 dll,您必须选择与 dll 组件架构匹配的项目的正确目标 CPU。错误将得到解决。右键项目名称>属性>编译>目标CPU -->你会来到目标CPU。

          【讨论】:

            【解决方案8】:

            这对我有用:

            1. useLegacyV2RuntimeActivationPolicy="true" 添加到App.Config
            2. 链接两个 dll - AForge.Video.dll, AForge.Video.FFMPEG.dll
            3. 复制到输出文件夹\AForge.NET Framework-2.2.5\Externals\ffmpeg\bin *.dlls

            【讨论】:

              猜你喜欢
              • 2012-09-15
              • 2018-08-21
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2015-09-11
              • 1970-01-01
              • 1970-01-01
              • 2021-12-12
              相关资源
              最近更新 更多