【发布时间】:2012-06-12 16:39:17
【问题描述】:
我下载了一些包含使用 Windows 窗体的 C# 代码的源代码。是否可以在Linux环境(Ubuntu 12.04)下编译代码并运行?
我已经尝试使用 mcs 成功编译一些 C# 源代码,并使用 mono 运行生成的 exe 文件。
源代码可以在here下载。如果可能,请描述您将如何编译和运行第 2 章/OpeningDocument 解决方案。
$ mcs Program.cs
Program.cs(3,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
编辑
$ gmcs -pkg:dotnet Program.cs
Program.cs(17,33): error CS0246: The type or namespace name `Form1' could not be found. Are you missing a using directive or an assembly reference?
Program.cs(17,25): error CS1502: The best overloaded method match for `System.Windows.Forms.Application.Run(System.Windows.Forms.Form)' has some invalid arguments
/usr/lib/mono/gac/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll (Location of the symbol related to previous error)
Program.cs(17,25): error CS1503: Argument `#1' cannot convert `object' expression to type `System.Windows.Forms.Form'
Compilation failed: 3 error(s), 0 warnings
【问题讨论】:
-
是的,这是可能的。工作原理与其余部分相同。
mcs你就完成了。为什么要问你是否没有尝试过? -
嗯,错误似乎很明显:您缺少程序集引用。
-
Mono 不支持 WPF 应用程序。您链接到的 zip 文件也无法打开。
-
@Ramhound 压缩文件没问题。蝉的答案有效。