【问题标题】:System.IO.FileNotFoundException: 'Could not load file or assemblySystem.IO.FileNotFoundException: '无法加载文件或程序集
【发布时间】:2019-04-03 13:14:42
【问题描述】:

我是 C# 初学者,尝试在项目中添加一个 DLL,但在运行项目时出现以下错误:

System.IO.FileNotFoundException: 'Could not load file or assembly 'Interop.TrueConf_CallXLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.'

我尝试在任何 CPU、X64 和 x86 上运行它,但它几乎是相同的错误。 你能帮我修一下吗?

以下是完整的例外:

    Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Interop.TrueConf_CallXLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
   at AxTrueConf_CallXLib.AxTrueConfCallX.AttachInterfaces()
   at System.Windows.Forms.AxHost.GetOcxCreate()
   at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
   at System.Windows.Forms.AxHost.CreateHandle()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The program '[20208] TruconfCall.exe' has exited with code 0 (0x0).

【问题讨论】:

  • 您是否尝试右键单击引用 -> 添加引用 -> 浏览 dll?
  • 它希望您导入的 DLL 在发布或调试/发布文件夹中。
  • “系统找不到指定的文件。”,您是否检查了该文件是否仍然存在于给定位置?
  • @NasriYatim 是的,我通过这种方式添加了参考。
  • @Innominatum 是的,该文件确实存在。

标签: c# .net dll


【解决方案1】:

错误提示

System.IO.FileNotFoundException:'无法加载文件或程序集'Interop.TrueConf_CallXLib,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null'或其依赖项之一。系统找不到指定的文件。'

所以我怀疑当前的 dll 依赖于更多的 dll。因此,与其使用浏览选项添加 dll,不如先安装 TrueConf SDK,如果 SDK 将库安装到 GAC,则从程序集中引用它。

【讨论】:

    【解决方案2】:

    任何 CPU

    您刚刚打开了一大堆蠕虫,因为 Any CPU 是一个 .Net 概念,它不会映射到更多本机进程,而且 CPU 本身也不支持它。而且由于 COM 使用本地库来工作,因此您确实必须在客户端和服务器上选择一种架构,并坚持下去。

    现在,你说 dll 存在于磁盘上,但它不会加载上述异常,所以你没有做任何奇怪的事情,比如从输出二进制文件夹中删除文件,或者做一些事情为了防止文件被复制,我能想到的最大问题是您缺少库的依赖项之一,也许是正确的 C++ 运行时(版本和架构!)?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-28
      • 1970-01-01
      • 2023-02-07
      • 1970-01-01
      • 2012-12-28
      • 2016-08-16
      • 2015-07-28
      相关资源
      最近更新 更多