c# - 从命令行运行 C# 可执行文件并指定所需库的路径

标签 c# mono

我正在运行一个 C# 可执行文件,该可执行文件是通过引用 .Net 库构建的。 .NetLibrary 是 C++ 库的包装器,它驻留在另一个文件夹中(与 .NetLibrary 不同的文件夹)。

C++ 库位于/usr/local bin 中 .Net 库位于/projects/csharp/NetWrapperProj/bin/Debug 可执行文件位于/projects/csharp/testharness/bin/Debug

正如您可能从路径中猜到的那样,我在 Linux (Ubuntu 10.0.4) 上使用 mono 运行 .Net。 单声道版本2.10。

如何为可执行文件指定所需的二进制文件 - 以避免引发未处理的异常:System.IO.FileNotFoundException 类型异常?

最佳答案

通常,DLL/库需要与可执行文件位于同一目录中。来自 Mono website :

If a library location has not been explicitly specified in a DllMap entry in an application or assembly .config file, Mono will search for a library in a few places:

  • The directory where the referencing image was loaded from.
  • In any place the system's dynamic loader is configured to look for shared libraries. For example on Linux this is specified in the $LD_LIBRARY_PATH environment variable and the /etc/ld.so.conf file. On windows the $PATH environment variable is used, instead.

您可以在 Mono 网站上阅读有关如何解决此问题的更多信息。

关于c# - 从命令行运行 C# 可执行文件并指定所需库的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6911599/

相关文章:

c# - 如何使用 Azure 的弹性数据库设置 Multi-Tenancy ?

c# - 从 IIS .Net 应用程序访问网络共享

c# - 相当于 OS X 上的 user32.dll

c# - 可以在 OSX .app 包中包含 Mono Runtimes 吗?

c# - Mono c# TextRenderingHint.SingleBitPerPixelGridFit Windows 与 Linux

javascript - 检测在其他控件 OnChanged 事件期间单击的控件

c# - 单元测试 DateTime.Now

c# - 使用 Rx 尝试某件事 5 次

C# 找不到类型或命名空间名称 `List'。但我正在导入 System.Collections.Generic;

mono - 构建失败。找不到类型 'System.Globalization.SortVersion'