How to reference these packages with Mono in order to compile(如何使用 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 引用这些包以进行编译
基础教程推荐
- C# 9 新特性——record的相关总结 2023-04-03
- 如果条件可以为空 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 将数据集转换为列表 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
