Hernán Casillas
Hernán Casillas

Reputation: 79

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

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.

Upvotes: 1

Views: 1486

Answers (1)

SushiHangover
SushiHangover

Reputation: 74174

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

Upvotes: 2

Related Questions