【问题标题】:issue with reference to .dll参考 .dll 的问题
【发布时间】:2017-07-12 07:34:35
【问题描述】:

目前正在使用 WinForms 和 7zip 解包器制作一个小程序。为了更容易添加对“SevenZipSharp.dll”的引用,一切正常,直到我想发布(调试)项目。当我在桌面中移动“.exe”文件时出现错误:

System.IO.FileNotFoundException:无法加载文件或 程序集 'X' 或其依赖项之一”。

我在 .dll 文件中嵌入资源集 + 复制本地:设置为 true

如何使这些程序在当前目录中没有 .dll 的情况下运行。

编辑

我是通过使用做到的

系统.反射

Solution here

但是我现在遇到了另一个问题

     System.TypeInitializationException: 'The type initializer for 'SevenZip.SevenZipLibraryManager' threw an exception.. ---> System.ArgumentException:  Path has an illegal format
   w System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   w System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   w System.IO.Path.InternalGetDirectoryName(String path)
   w System.IO.Path.GetDirectoryName(String path)
   w SevenZip.SevenZipLibraryManager..cctor()
   --- End of inner exception stack trace ---

   w SevenZip.SevenZipLibraryManager.SetLibraryPath(String libraryPath)
   w SevenZip.SevenZipBase.SetLibraryPath(String libraryPath)

【问题讨论】:

  • 不是这方面的专家,但我认为它必须是
  • 你到底是什么意思?不是不可能吗?

标签: c# dll reference sevenzipsharp typeinitializeexception


【解决方案1】:

您可能希望将引用的库放在同一个文件夹中,或者您也可以在 GAC 中注册它们。

【讨论】:

  • 我在主项目文件夹、\bin 文件夹和\Debug\bin 文件夹中尝试了它......什么都没有
  • 请将 .exe 保存在与引用库 (.dll) 相同的位置
  • 我的问题是我想在 .exe 文件中包含这个 .dll
  • 你为什么要这样做。但是,您可以尝试 ILMerge (microsoft.com/en-us/download/details.aspx?id=17630)。 Thjere 将是可以提供帮助的实用程序。
  • 我使用 System.Reflection 解决了这个问题。我遇到了另一个错误 *已编辑第一篇文章
猜你喜欢
  • 2010-10-30
  • 2012-11-12
  • 2018-05-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-03
  • 2011-01-20
  • 1970-01-01
相关资源
最近更新 更多