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

How to reference these packages with Mono in order to compile(如何使用 Mono 引用这些包以进行编译)

本文介绍了如何使用 Mono 引用这些包以进行编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to compile a C# script with Mono on Debian by command line, like this:

gmcs Main.cs

但是,我收到以下错误:

However, I get the following error:

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 顶部的这些引用:

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 一起提供.

I understand that I have to tell Mono which libraries to include by adding -pkg:whatever. My problem is that I do not know what these libraries are called, so I don't know what command is used to include them. Actually, I don't even know whether I have to download these libraries from somewhere or whether they come with Mono.

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

Note also that the last 2 are the iTextSharp library, for which I have itextsharp.dll just placed in the same directory as the script, since I don't know what else to do with it.

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

Please could someone explain to me how to get the file to compile!

推荐答案

试试这个:

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

使用较新版本的单声道,试试这个.

With newer versions of mono, try this.

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

这篇关于如何使用 Mono 引用这些包以进行编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何使用 Mono 引用这些包以进行编译

基础教程推荐