如何从OSX中的终端运行Windows.Forms C#程序? [英] How to run a Windows.Forms C# program from Terminal in OSX?
问题描述
我必须在学校的C#课程中使用System.Windows.Forms,但我拥有一台Macbook,Visual Studio表示它不存在.我读到如果安装 Mono ,然后使用 mcs hello.cs -pkg:dotnet
从终端编译并运行它,则可以使用WinForms."hello.cs"只是一个使用System.Windows.Forms的Hello World程序...它可以编译,但是当我执行 mono hello.exe
时,它说:
I have to use System.Windows.Forms for my C# course in school but I own a Macbook and Visual Studio says that it doesn't exist. I read that I could use WinForms if I installed Mono and then compile and run it from terminal using mcs hello.cs -pkg:dotnet
. "hello.cs" is just a Hello World program using System.Windows.Forms... it compiles but when I do mono hello.exe
it says:
WARNING: The Carbon driver has not been ported to 64bits, and very few
parts of Windows.Forms will work properly, or at all
...,然后是一堆东西,我将其留在 pastebin 中!
... and then a bunch of stuff that I will leave it here in pastebin!
在OSX中|他们说要使用Windows.Mono网站,Mono的体系结构必须是32位,并且要更改它,我必须做: mono --arch = 32
,但是当我这样做时,它并没有这样做.似乎什么也没做,如果我将其编译并再次运行"hello.exe",它将打印出我之前提到的相同内容.
In the OSX | Mono website they say that in order to use Windows.Forms the architecture of Mono must be 32bits and to change it I have to do: mono --arch=32
but when I do it, it doesn't seem to do anything and if I compile it and run again the "hello.exe" it prints the same thing I mentioned before.
请帮助我!我的Mac很旧,无法在其上运行Windows.
Please help me! My Mac is old and running Windows on it is not an option.
推荐答案
编译 hello.cs
代码与较旧的 mcs
编译器:
/Library/Frameworks/Mono.framework/Commands/mcs -pkg:dotnet ./hello.cs
或使用更新的基于Rosyln的 csc
编译器:
Or use the newer Rosyln-based csc
compiler:
/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
这篇关于如何从OSX中的终端运行Windows.Forms C#程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!