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

Ala*_*air 32 .net c# mono

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

gmcs Main.cs
Run Code Online (Sandbox Code Playgroud)

但是,我收到以下错误:

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
Run Code Online (Sandbox Code Playgroud)

这些参考在顶部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;
Run Code Online (Sandbox Code Playgroud)

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

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

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

ick*_*fay 51

试试这个:

gmcs /reference:System.Drawing.dll /reference:itextsharp.dll Main.cs
Run Code Online (Sandbox Code Playgroud)

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

mcs /reference:System.Drawing.dll /reference:itextsharp.dll Main.cs
Run Code Online (Sandbox Code Playgroud)

  • 使用新的单声道版本,现在只有一个编译器,那就是mcs. (3认同)

mil*_*lia 6

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

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?  
Run Code Online (Sandbox Code Playgroud)

我的程序中有这些引用:

using System;
using System.Drawing;
using System.Windows.Forms; 
Run Code Online (Sandbox Code Playgroud)

我从ubuntuforums获得了解决方案:

 gmcs -pkg:dotnet *.cs
Run Code Online (Sandbox Code Playgroud)

  • mcs -pkg:dotnet * .cs为我工作! (2认同)