Reputation: 3752
I downloaded a few source codes containing C# code that uses windows forms. Is it possible to compile the codes under the Linux environment (Ubuntu 12.04) and run it?
I already tried successfully to compile a few C# source codes with mcs and run the resulting exe file with mono.
The source codes can be downloaded here. If it's possible please describe how would you compile and run chapter 2/OpeningDocument solution.
$ mcs Program.cs
Program.cs(3,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
EDIT
$ gmcs -pkg:dotnet Program.cs
Program.cs(17,33): error CS0246: The type or namespace name `Form1' could not be found. Are you missing a using directive or an assembly reference?
Program.cs(17,25): error CS1502: The best overloaded method match for `System.Windows.Forms.Application.Run(System.Windows.Forms.Form)' has some invalid arguments
/usr/lib/mono/gac/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll (Location of the symbol related to previous error)
Program.cs(17,25): error CS1503: Argument `#1' cannot convert `object' expression to type `System.Windows.Forms.Form'
Compilation failed: 3 error(s), 0 warnings
Upvotes: 1
Views: 7415
Reputation: 37995
If you're not using the latest version of Mono, this should work:
gmcs -pkg:dotnet *.cs
The latest version of mono uses mcs
instead of gmcs
. In the previous ones, mcs
targets .NET 1.1.
Upvotes: 4
Reputation: 11730
You may wish to run your code against the mono migration analyser to see what fails or isn't supported. You can find the tool here: http://www.mono-project.com/MoMA. NOTE For the tool to work you will need access to a windows machine.
You can also take a look at current mono compatibility with various .Net features at http://www.mono-project.com/Compatibility.
Specifically for windows forms see: http://www.mono-project.com/WinForms
Hope this helps.
Upvotes: 2