Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mono on Windows 2000 SP4 [closed]

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?

like image 743
kol Avatar asked Nov 13 '12 15:11

kol


2 Answers

I tried out every minor version between 2.0 and 3.0. I found that versions <=2.4 work, but versions >=2.6 do not. I checked out the Release Notes for v2.6, but could not find anything that could explain this. Then I googled "mono 2.6 windows 2000" and found that there is a critical bug on Windows 2000:

Entry point getaddrinfo not found in WS2_32.DLL in Windows 2000

In my case, error reporting and Dr. Watson is turned off, so the error message is probably swallowed by Windows (I did the tests on an industrial PC, where error reporting would make important programs hang). I tried to turn it on, but I still got no error message - mono and mcs simply stop without doing anything. In spite of this, I believe this is the problem because this is a version-related, show-stopper bug, and in my case the versions are the same.

Mono developer Zoltan Varga added the following comment to the bug report:

Unlike freeaddrinfo, getaddrinfo is actually required by parts of mono so its usage cannot be avoided without disabling some functionality. MSDN suggests including Wspiapi.h, which we cannot do since it is part of MS's Platform SDK, and it is not in cygwin/mingw, which we use for compiling releases of mono. So you probably need to compile your own version of mono on windows and work around these problems.

The solution suggested by MSDN, which Zoltan referred to is the following:

Support for getaddrinfo on Windows 2000 and older versions - The getaddrinfo function was added to the Ws2_32.dll on Windows XP and later. To execute an application that uses this function on earlier versions of Windows, then you need to include the Ws2tcpip.h and Wspiapi.h files. When the Wspiapi.h include file is added, the getaddrinfo function is defined to the WspiapiGetAddrInfo inline function in the Wspiapi.h file. At runtime, the WspiapiGetAddrInfo function is implemented in such a way that if the Ws2_32.dll or the Wship6.dll (the file containing getaddrinfo in the IPv6 Technology Preview for Windows 2000) does not include getaddrinfo, then a version of getaddrinfo is implemented inline based on code in the Wspiapi.h header file. This inline code will be used on older Windows platforms that do not natively support the getaddrinfo function.

This bug was filed in 2010, got priority level 5, and has not been solved since then. This basically means that until someone solves this bug, Windows 2000 is not supported by Mono versions >=2.6.

(I'm planning to try to apply the modifications suggested by MSDN and rebuild Mono 3.0 using VS2005, but this does not seem to be an easy task. In case I succeed, I will update my answer.)

like image 146
kol Avatar answered Nov 07 '22 15:11

kol


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.

like image 2
Bastian Eicher Avatar answered Nov 07 '22 14:11

Bastian Eicher