5

I need to develop C# applications, but i use Linux (ubuntu), I found MonoDevelop, but I don't understand if i can write .NET applications from Linux to use on Windows, so the development on linux and the execution on Windows. are them compatible?

On the Mono website I found:

Mono is a software platform designed to allow developers to easily create cross platform applications.

What does it means? Can I write on Linux c# applications that can run wherever the .NET framework is installed?

Thank you for the clarification

5 Answers 5

7

Any C# code you compile from MonoDevelop or anywhere else can be run on any platform with either Mono or the .NET Framework. As long as the linux system has Mono installed, it can run any compiled C# application, including .exe's copied from a Windows machine.

The reason for this is that when you compile a C# application, it's not being compiled to native system code, it's being compiled to CIL. When you run the program, it automatically JIT compiles your code for the system it's running on, leaving the original executable intact. Both the .NET Framework on Windows and Mono on everything else can read and compile the CIL bytecode.

And one thing to keep in mind, Mono doesn't have the entire .NET Framework stack available. Almost all of the BCL is intact, but libraries like WPF are not available on Mono. Mono recommends you use GTK# for your GUIs.

Sign up to request clarification or add additional context in comments.

Comments

5

Yes, you can use mono to create .NET applications that will run on Linux, Windows and Macs.

Mono is:

It is an open source implementation of Microsoft's .Net Framework based on the ECMA standards for C# and the Common Language Runtime.

This means that so long as you don't write code that is platform specific, you can run it on all platforms that .NET can run on. (So, instead of concatenating paths using \ or / you use Path.Combine, and instead of hardcoding linebreaks as \n you use Environment.NewLine and such).

Comments

2

Another advantage is that the mono development tools are free. (see: http://www.mono-project.com/Main_Page)

Comments

0

You can indeed write .NET code in Mono on Linux and run the application on Windows, Mac OS X and Linux.
But keep in mind that the full .NET stack is not available for you. Most noticeable is the complete lack of WPF support.

Comments

0

You can as long as you are careful to not assume anything about things like file system layout and use libraries that are also portable. Graphical interfaces in particular are problematic: Windows.Forms looks alien on Linux, and Gtk may feel a little out of place on Windows.

3 Comments

hmmm, so If i use Gtk and create the .exe file I will have problem porting it to windows?
Gtk# is ported to windows so you won't have problems as such, but the components don't behave like native Windows components in 100% of the situations. Whether this is a problem depends on the complexity of the user interface and the expectations of your users.
Yes, you could put it that way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.