问题
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