如何在OSX中从终端运行Windows.Forms C#程序?

时间:2017-09-09 01:17:21

标签: c# .net macos winforms mono

我必须在学校使用System.Windows.Forms作为我的C#课程,但我拥有一台Macbook,而Visual Studio则认为它不存在。我读过如果我安装 Mono 然后使用mcs hello.cs -pkg:dotnet从终端编译并运行它,我可以使用WinForms。 “hello.cs”只是一个使用System.Windows.Forms的Hello World程序...它编译但是当我mono hello.exe它说:

WARNING: The Carbon driver has not been ported to 64bits, and very few 
parts of Windows.Forms will work properly, or at all

...然后是一堆我将把它留在pastebin中的东西!

在OSX中| Mono网站他们说,为了使用Windows.Forms Mono的体系结构必须是32位并且要改变它我必须做的事:mono --arch=32但是当我这样做时,它似乎没有做任何事情,如果我编译它并再次运行“hello.exe”它打印出我之前提到的相同内容。

请帮帮我!我的Mac已经老了,在它上面运行Windows不是一种选择。

1 个答案:

答案 0 :(得分:2)

使用旧的mcs编译器编译hello.cs代码:

/Library/Frameworks/Mono.framework/Commands/mcs -pkg:dotnet ./hello.cs

或者使用较新的基于Rosyln的csc编译器:

/Library/Frameworks/Mono.framework/Commands/csc ./hello.cs
Microsoft (R) Visual C# Compiler version 2.3.1.61919 (57c81319)
Copyright (C) Microsoft Corporation. All rights reserved.

使用mono选项--arch=32运行它:

/Library/Frameworks/Mono.framework/Commands/mono --arch=32 ./hello.exe

或使用mono32

/Library/Frameworks/Mono.framework/Commands/mono32 ./hello.exe
相关问题