Like, if I write a program on windows using C# and the .NET framework, then drop the code on a Linux machine running mono, will it run exactly the same? Or would I have to rewrite it to work with Mono's libraries?
views:
182answers:
3It's a cross-platform implementation of C# and the implementation is compatible with .NET.
So, I'd say it's the former of the two options that you list.
Short answer: it depends.
Longer answer: Mono'c C# compiler produces IL which is the same as what .NET produces.
The problem is with the extras; i.e. using something in .NET for which there is no Mono library available (e.g. WPF).
Another area of incompatibility is where Win32-specific APIs are used.
So, sort of is the best answer.
will it run exactly the same? Or would I have to rewrite it to work with Mono's libraries?
This really depends on what your program does, and how it's written.
If you use pure C# and core .NET framework features that are supported on Mono, they will "just work", with no changes. However, if you use unsupported features (ie: any 3rd party libs built around native interop, or WPF, etc), they will not work.
It's a very good idea to run the Mono Migration Analyzer regularly on your assemblies as you develop them. This will tell you of any incompatibilities.