Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference these packages with Mono in order to compile

Tags:

c#

.net

mono

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 

These the references at the top of 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; 

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.

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!

like image 911
Alasdair Avatar asked Nov 25 '11 04:11

Alasdair


People also ask

How do I install mono on prefix?

Mono releases are distributed as .tar.xz packages from the Mono web site. Once you have your dependencies installed all you need to do is run the following command where VERSION is the package version number and PREFIX is your installation prefix: By the end of this process, you will have Mono installed on your PREFIX directory.

What compiler versions are supported by Mono?

Mono depends on GCC 4.8+ or Clang 3.3+ (it needs to support C++11) and on CMake 2.8.10. The table below shows a (not necessarily complete list) of the compiler versions in various distributions.

How do I load third party Mono assemblies into the compiler?

The compiler will automatically load assemblies that are located in the same directory as the compiler (by default /usr/lib/mono/1.0) and these include all the assemblies that are part of the standard Mono. But for third party assemblies, it is necessary to indicate a directory that holds the assembly to link against.

Can I install multiple versions of mono at the same time?

If you have more than one Mono installation (for example to keep multiple versions around), you will want to read the document on Parallel Mono Environments on how to keep your various Mono installations separate. It is strongly advised not to install Mono from source in /usr as it might conflict with Mono as installed by the Mono package.


1 Answers

Try this:

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 
like image 138
icktoofay Avatar answered Sep 22 '22 07:09

icktoofay