c# - Windows 2000 SP4 上的单声道

标签 c# windows compiler-construction mono windows-2000

<分区>

在良好的旧 Win2k 上,the highest supported version of the .NET Framework is 2.0 .如果想要运行现代 C# 应用程序(例如,使用 LINQ 的应用程序),则 Mono Framework可能是解决方案。不幸的是,Mono 是否支持 Windows 2000 尚不清楚。 Download page说最新版本(3.0.1-beta)“适用于所有版本的 Windows XP、2003、Vista 和 Windows 7”,但安装程序显示的发行说明声称“此版本在 Windows 2000 或更高版本上运行”。

作为快速测试,我尝试使用不同版本的 Mono(2.0、2.10.9、3.0.1-beta)在 Win2k 机器上编译并运行以下代码:

// 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));
  }
}

我打开Mono Command Prompt,将工作目录更改为Test.cs 的工作目录,并尝试通过mcs Test.cs 编译它。

  • 旧版本 2.0 有效,我只需要使用 gmcs 而不是 mcs。我可以在 Mono 上成功运行可执行文件 2.0。 (当我尝试在 .Net 2.0 上运行它时,如我所料,出现了异常。)
  • 对于版本 2.10.93.0.1-beta什么都没发生:没有创建 exe,也没有显示错误消息。这些版本适用于 Windows XP,我可以编译代码并运行可执行文件。

问题: Mono 仍然支持 Windows 2000 吗? Mono 在 2.0 和 3.0 版本之间发生了什么,这可以解释上面提到的编译问题?如何才能使最新版本在 Win2k 上运行?

最佳答案

我尝试了 2.0 到 3.0 之间的每个次要版本。我发现版本 <=2.4 有效,但版本 >=2.6 无效。我检查了 Release Notes for v2.6 , 但找不到任何可以解释这一点的东西。然后我用谷歌搜索“mono 2.6 windows 2000”,发现有一个critical bug on Windows 2000。 :

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

在我的例子中,错误报告和 Dr. Watson 已关闭,因此错误消息可能被 Windows 吞没(我在工业 PC 上进行了测试,错误报告会使重要程序挂起)。我试图打开它,但我仍然没有收到任何错误消息 - monomcs 只是停止而不做任何事情。尽管如此,我认为这就是问题所在,因为这是一个与版本相关的、显示停止的错误,在我的情况下,版本是相同的。

Mono 开发者 Zoltan Varga 在错误报告中添加了以下评论:

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.

solution suggested by MSDN ,Zoltan 所指的内容如下:

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.

此错误于 2010 年提交,优先级为 5,此后一直未解决。这基本上意味着在有人解决这个错误之前,Windows 2000 不受 Mono 版本 >=2.6 的支持。

(我打算尝试应用 MSDN 和 rebuild Mono 3.0 using VS2005 建议的修改,但这似乎不是一件容易的事。如果我成功了,我会更新我的答案。)

关于c# - Windows 2000 SP4 上的单声道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13363427/

相关文章:

windows - SQLDeveloper 不会启动

c++ - 什么是带有 gui 和 linux 下的 c++ 的最佳稳定编辑器和编译器?

c# - 使用 CreateFileAsync 创建的文件在哪里?

c# - 如何创建连接到同一数据库的两个应用程序?

windows - 任何让我重新登录 "locked"Windows 7 的 Windows API?

windows - 什么 SCM 在 Windows 和 Linux 下支持符号链接(symbolic link)?

C 编译器预处理器输出

java - Java编译错误,找不到符号

c# - 在asp.net mvc View 中创建viewModel对象

c# - 如何使用非托管导出 (Robert Giesecke) 将结构数组从 .NET 传递到 Delphi?