如何使用Mono引用这些包以便编译

我正在尝试使用命令行在Debian上使用Mono编译C#脚本,如下所示:

gmcs Main.cs 

但是,我收到以下错误:

 Main.cs(6,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference? Main.cs(7,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference? Main.cs(12,7): error CS0246: The type or namespace name `iTextSharp' could not be found. Are you missing a using directive or an assembly reference? Main.cs(13,7): error CS0246: The type or namespace name `iTextSharp' could not be found. Are you missing a using directive or an assembly reference? Main.cs(1526,31): error CS0246: The type or namespace name `Bitmap' could not be found. Are you missing a using directive or an assembly reference? Main.cs(6,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference? Main.cs(7,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference? Main.cs(12,7): error CS0246: The type or namespace name `iTextSharp' could not be found. Are you missing a using directive or an assembly reference? Main.cs(13,7): error CS0246: The type or namespace name `iTextSharp' could not be found. Are you missing a using directive or an assembly reference? Compilation failed: 9 error(s), 1 warnings 

这些是Main.cs顶部的Main.cs

 using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Xml; using iTextSharp.text; using iTextSharp.text.pdf; 

我知道我必须通过添加-pkg:whatever来告诉Mono要包含哪些库。 我的问题是我不知道这些库被调用了什么,所以我不知道用什么命令来包含它们。 实际上,我甚至不知道是否必须从某个地方下载这些库,或者它们是否附带Mono。

另请注意,最后2个是iTextSharp库,我将itextsharp.dll放在与脚本相同的目录中,因为我不知道还有什么可以处理它。

请有人向我解释如何编译文件!

试试这个:

 gmcs /reference:System.Drawing.dll /reference:itextsharp.dll Main.cs 

使用较新版本的mono,试试这个。

 mcs /reference:System.Drawing.dll /reference:itextsharp.dll Main.cs 

这是另一个解决方案,在我收到此错误的类似情况下对我有用:

 Eventdemo.cs(2,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing `System.Drawing' assembly reference? Eventdemo.cs(3,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference? │ Eventdemo.cs(8,19): error CS0246: The type or namespace name `Form' could not be found. Are you missing an assembly reference? 

我的程序中有这些引用:

 using System; using System.Drawing; using System.Windows.Forms; 

我从ubuntuforums获得了解决方案:

  gmcs -pkg:dotnet *.cs 

我收到了这个错误,当我只需要使用System.Net.Http时,我使用了:

 $mcs /reference:System.Net.Http.dll Program.cs 

它对我来说很好。 当我尝试包含System.Net.Http.dll的完整路径时,它无法正常工作。 也就是说,抬头,单声道跟踪路径。 另外,我有最新版的mono。