我正在运行一个 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/