Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is developing in Mono cross-platform?

In what measure is developing with mono cross-platform? How do I compile for Windows (in Linux), how do I run things in Linux (because there is no .NET JIT compiler)?

So what are the particularities of developing with Mono? What are the advantages over developing with Visual Studio (except cross-platform thinghie)?

like image 616
Andrei Zisu Avatar asked Aug 07 '10 06:08

Andrei Zisu


People also ask

What is mono cross-platform?

Mono is a software platform designed to allow developers to easily create cross platform applications part of the . NET Foundation. Sponsored by Microsoft, Mono is an open source implementation of Microsoft's . NET Framework based on the ECMA standards for C# and the Common Language Runtime.

Is Mono owned by Microsoft?

Mono is a free and open-source . NET Framework-compatible software framework. Originally by Ximian, it was later acquired by Novell, and is now being led by Xamarin, a subsidiary of Microsoft and the . NET Foundation.

What is difference between .NET Core and Mono?

NET Core, which natively only allows you to build console apps and web applications, mono allows you to build many application types available in . NET Framework, including GUI-enabled desktop apps. So, if mono can do everything that .

What is the difference between Xamarin and Mono?

Xamarin is primarily a platform for developing mobile applications (Android and iPhone) using C#. The Mono project is an open-source port of the . NET framework. It is most commonly used to run .


2 Answers

Developing in Mono is definitely cross-platform with a caveat emptor:

  • Strive to steer clear of Windows specific APIs
  • No interoperability with the native Windows APIs... or... you can #ifdef out the Windows API and provide your own Mono wrapper in order to minimize code changes, for example, there's a DLL wrapper that uses Interop to invoke a Win32 method such as 'GetFont', this is a hypothetical example, GetFont will return the Font information, under Mono, that does not exist but however you can create a fake wrapper that returns nothing and incorporate the #ifdef macro to use the wrapper when compiling under Mono, and switch off the macro when compiling under Windows, how you implement the wrapper is up to you.
  • Do not use advanced GUI properties that may not be present in Mono.
  • Use the Environment property such as NewLine to make it independant of Unix's CR and Win32's CRLF, same apply for Path Separator, for Unix '/' and for Win32 '\'.
  • Serialization is slightly different under Mono, you serialize an object on Mono, do not kid yourself into thinking it will be de-serialized under Win32 and vice versa.

Lastly but not least, keep checking from Mono to Win32 and back again, keep testing and testing it.

like image 100
t0mm13b Avatar answered Nov 09 '22 05:11

t0mm13b


Much of the mono runtime is compatible with the CLR, as they follow the same standard.

This means that once you compile your code (in Mono or visual studio), so long as you make sure to only use features supported by both (for example no WMI stuff in mono) and write your application to be platform aware, using best practices (examples are using Path.Combine to build file and directory paths, using Environment.NewLine for outputting new lines and more), your application can run unmodified on any platform that has either Mono or the CLR (this includes Windows, Linux and Mac).

You can develop with mono in visual studio, so the part of your question regarding that is moot.

like image 32
Oded Avatar answered Nov 09 '22 05:11

Oded