tags:

views:

182

answers:

3

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?

+2  A: 

It'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.

http://www.mono-project.com/Main_Page

Ian P
+3  A: 

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.

kmontgom
+5  A: 

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.

Reed Copsey
One key note is to also test your application on Mono/Linux directly. I have one application that fails to pass MoMA, but it in fact can run fine on Mono/Linux. I will try to report such false alarm later. :)
Lex Li
Besides, .NET application looks much different on Mono under openSUSE Linux theme :)
Lex Li
@Lex: True (about the look), but .NET applications look very different on XP vs. a themed W7 box, too ;)
Reed Copsey