如何告诉mono在何处查找图书馆?

时间:2015-01-21 18:02:56

标签: c# mono

我试图将Gnu.Getopt用于单声道。在这里提出其他问题后,我已经完成了:

% gacutil -i .../gnu.getopt.net-0.9.1/Gnu.Getopt/bin/Release/Gnu.Getopt.dll

有效:

% gacutil -l | grep Gnu.Getopt
Gnu.Getopt, Version=0.9.1.24287, Culture=neutral, PublicKeyToken=d014b4ccdc53511a

但是单声道无法找到它:

% grep Gnu Program.cs
using Gnu.Getopt;
% mcs Program.cs
Program.cs(4,7): error CS0246: The type or namespace name `Gnu' could not be found. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings

提供DLL的显式路径可以正常工作:

% mcs -r:.../gnu.getopt.net-0.9.1/Gnu.Getopt/bin/Release/Gnu.Getopt.dll Program.cs
%

我错过了什么?

更新

我注意到/usr/lib/mono/4.5具有指向/usr/lib/mono/gac中所有内容的符号链接(例如System.Core.dll - > ../gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll)。我插入了Gnu.Getopt.dll的符号链接,但症状仍然存在。

3 个答案:

答案 0 :(得分:1)

在单声道列表上发布并进一步搜索之后,答案似乎是“不要使用Gnu.Getopt”; use Ndesk.Options instead根据GetOpt library for C#

答案 1 :(得分:1)

如果您查找使用单声道命令行选项解析器的常用方法,则Options.cs中有一个文件/usr/lib/mono-source-libs(将/usr更改为安装单声道的前缀)。   要引用系统上安装的文件的最新版本,可以在编译器中使用-pkg:mono-options命令行选项(-pkgmcs编译器选项,它允许引用系统包)。 或者您可以将文件复制到项目中,并像使用其他任何cs文件一样使用它。

答案 2 :(得分:0)

根据mcs documentation编译时默认引用的唯一程序集:

mscorlib.dll
System.dll

Microsoft的CSC编译器具有类似的行为,默认情况下会引用一组程序集,但其他程序集需要传递给编译器,即使是GAC中的那些程序集。