Search code examples
c#windowscompiler-constructionmonowindows-2000

Mono on Windows 2000 SP4


On good old Win2k, the highest supported version of the .NET Framework is 2.0. If one would like to run modern C# applications (for example, which use LINQ), the Mono Framework may be the solution. Unfortunately it is not clear whether Windows 2000 is supported by Mono. The Download page says the latest version (3.0.1-beta) "works on all versions of Windows XP, 2003, Vista and Windows 7", but the Release Notes displayed by the installer claims that "this build runs on Windows 2000 or later".

As a quick test, I tried to compile and run the following code on a Win2k box, using different versions of Mono (2.0, 2.10.9, 3.0.1-beta):

// Test.cs
using System;
using System.Linq;

public static class Test
{
  public static void Main()
  {
    Console.WriteLine(Environment.Version);
    int[] numbers1 = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
    var numbers2 = from number in numbers1 where number < 5 select number;
    Func<int, int> negate = number => -1 * number;
    foreach (var number in numbers2)
      Console.WriteLine(negate(number));
  }
}

I opened the Mono Command Prompt, changed the working directory to that of Test.cs, and tried to compile it by mcs Test.cs.

  • The old version 2.0 worked, I just had to use gmcs instead of mcs. I could successfully run the executable on Mono 2.0. (When I tried to run it on .Net 2.0, I got an exception, as I expected.)
  • In case of version 2.10.9 and 3.0.1-beta, nothing happened: no exe was created and no error message was displayed. These versions work on Windows XP, I could compile the code and run the executable.

Questions: Is Windows 2000 still supported by Mono? What happened to Mono between version 2.0 and 3.0, which could explain the the above mentioned compilation problem? What could be done to make the latest version work on Win2k?


Solution

  • You do not need anything newer than .NET 2.0 to get most of the nice .NET 3.5 features. Type inference, lambda methods, etc. are supported by the C# 3 compiler included in Visual Studio 2008-2012 even when targeting .NET 2.0.

    But here's the important link (pun intended ;) ): http://code.google.com/p/linqbridge/ LinqBridge gives you full Linq-to-Objects support on .NET 2.0.