2011-11-25 33 views
25

Tôi đang cố gắng để biên dịch một kịch bản C# với Mono trên Debian bằng dòng lệnh, như thế này:Làm thế nào để tham khảo các gói với Mono để biên dịch

gmcs Main.cs 

Tuy nhiên, tôi nhận được lỗi sau:

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 

những tài liệu tham khảo ở đầu 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; 

tôi hiểu rằng tôi phải nói Mono có thư viện để bao gồm bằng cách thêm -pkg:whatever. Vấn đề của tôi là tôi không biết những gì các thư viện này được gọi là, vì vậy tôi không biết những gì lệnh được sử dụng để bao gồm chúng. Trên thực tế, tôi thậm chí không biết liệu tôi có phải tải xuống các thư viện này từ đâu đó hay liệu họ có đi với Mono hay không.

Cũng lưu ý rằng 2 thư viện cuối cùng là thư viện iTextSharp, mà tôi có itextsharp.dll chỉ được đặt trong cùng thư mục với tập lệnh, vì tôi không biết phải làm gì khác với nó.

Xin vui lòng ai đó có thể giải thích cho tôi cách lấy tệp để biên dịch!

Trả lời

42

Hãy thử điều này:

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

Với phiên bản mới hơn của mono, hãy thử này.

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

Nó hoạt động. Cảm ơn bạn! Tôi sẽ chấp nhận câu trả lời của bạn khi trang web cho phép tôi. – Alasdair

+2

Với các phiên bản mono mới, hiện chỉ có một trình biên dịch và đó là mcs. – Salil

+0

Trên OSX nó sẽ là 'mcs -reference: System.Drawing.dll Main.cs', v.v. Và điều này sẽ tìm thấy các tập tin trong cùng một thư mục. Có lẽ hiển nhiên, nhưng bạn không bao giờ biết. – atomicules

5

Đây là một giải pháp đó là làm việc cho tôi trong một trường hợp tương tự mà tôi đã nhận lỗi này:

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? 

Tôi đã có những tài liệu tham khảo trong chương trình của tôi:

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

tôi có những giải pháp từ ubuntuforums:

gmcs -pkg:dotnet *.cs 
+1

mcs -pkg: dotnet * .cs đã hoạt động cho tôi! – Tiago

0

Tôi đã nhận lỗi này, và khi tôi chỉ cần thiết để sử dụng System.Net.Http, tôi đã sử dụng:

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

và nó làm việc tốt cho tôi. Khi tôi cố gắng bao gồm đường dẫn đầy đủ đến System.Net.Http.dll, nó không hoạt động. Đó là để nói, đứng đầu, mono theo dõi các con đường. Ngoài ra, tôi có phiên bản mới nhất của mono.

Các vấn đề liên quan