How to run a Windows.Forms C# program from Terminal in OSX?

与世无争的帅哥 提交于 2021-02-08 04:00:43

问题


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

... and then a bunch of stuff that I will leave it here in pastebin!

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.

Please help me! My Mac is old and running Windows on it is not an option.


回答1:


Compiling the hello.cs code with the older mcs compiler:

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

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.

Run it with mono with the --arch=32 option:

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

Or use mono32:

/Library/Frameworks/Mono.framework/Commands/mono32 ./hello.exe


来源:https://stackoverflow.com/questions/46126322/how-to-run-a-windows-forms-c-sharp-program-from-terminal-in-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!