将基于 Windows 的 HDInsight 的 .NET 解决方案迁移到基于 Linux 的 HDInsightMigrate .NET solutions for Windows-based HDInsight to Linux-based HDInsight

基于 Linux 的 HDInsight 群集使用 Mono (https://mono-project.com) 运行 .NET 应用程序。Linux-based HDInsight clusters use Mono (https://mono-project.com) to run .NET applications. Mono 支持将 .NET 组件(例如 MapReduce 应用程序)与基于 Linux 的 HDInsight 配合使用。Mono allows you to use .NET components such as MapReduce applications with Linux-based HDInsight. 在此文档中,了解如何迁移为基于 Windows 的 HDInsight 群集创建的 .NET 解决方案,以与基于 Linux 的 HDInsight 上的 Mono 配合使用。In this document, learn how to migrate .NET solutions created for Windows-based HDInsight clusters to work with Mono on Linux-based HDInsight.

Mono 与 .NET 的兼容性Mono compatibility with .NET

HDInsight 版本 3.6 附带了 Mono 版本 4.2.1。Mono version 4.2.1 is included with HDInsight version 3.6. 有关包含在 HDInsight 中的 Mono 版本的详细信息,请参阅 HDInsight 组件版本For more information on the version of Mono included with HDInsight, see HDInsight component versions.

有关 Mono 与 .NET 间兼容性的详细信息,请参阅 Mono 兼容性 (https://www.mono-project.com/docs/about-mono/compatibility/) 文档。For more information on compatibility between Mono and .NET, see the Mono compatibility (https://www.mono-project.com/docs/about-mono/compatibility/) document.

Important

SCP.NET 框架与 Mono 兼容。The SCP.NET framework is compatible with Mono. 有关将 SCP.NET 与 Mono 配合使用的详细信息,请参阅使用 Visual Studio 为 HDInsight 上的 Apache Storm 开发 C# 拓扑For more information on using SCP.NET with Mono, see Use Visual Studio to develop C# topologies for Apache Storm on HDInsight.

自动可移植性分析Automated portability analysis

.NET Portability Analyzer 可以用于生成有关应用程序和 Mono 之间不兼容性的报表。The .NET Portability Analyzer can be used to generate a report of incompatibilities between your application and Mono. 使用以下步骤配置该分析器,以检查应用程序是否可以移植到 Mono:Use the following steps to configure the analyzer to check your application for Mono portability:

  1. 安装 .NET Portability AnalyzerInstall the .NET Portability Analyzer. 在安装期间,选择要使用的 Visual Studio 版本。During installation, select the version of Visual Studio to use.

  2. 在 Visual Studio 2015 中,依次选择“分析” > “可移植性分析器设置”,并确保在“Mono”部分选中了“4.5”。From Visual Studio 2015, select Analyze > Portability Analyzer Settings, and make sure that 4.5 is checked in the Mono section.

    在分析器设置的 Mono 部分选中了 4.5

    选择“确定”以保存配置。Select OK to save the configuration.

  3. 依次选择“分析” > “分析程序集可移植性”。Select Analyze > Analyze Assembly Portability. 选择包含解决方案的程序集,并选择“打开”以开始分析。Select the assembly that contains your solution, and then select Open to begin analysis.

  4. 分析完成后,依次选择“分析” > “查看分析报表”。Once analysis is complete, select Analyze > View analysis reports. 在“可移植性分析结果”中,选择“打开报表”以打开某个报表。In Portability Analysis Results, select Open report to open a report.

    可移植性分析器结果对话框

Important

分析器无法捕获解决方案的每个问题。The analyzer cannot catch every problem with your solution. 例如,如果 Mono 在 Windows 上运行,文件路径 c:\temp\file.txt 视为有效。For example, a file path of c:\temp\file.txt is considered OK if Mono is running on Windows. 同一路径在 Linux 平台上无效。The same path is not valid on a Linux platform.

手动可移植性分析Manual portability analysis

使用应用程序可移植性 (https://www.mono-project.com/docs/getting-started/application-portability/) 文档中的信息执行代码的手动审核。Perform a manual audit of your code using the information in the Application Portability (https://www.mono-project.com/docs/getting-started/application-portability/) document.

修改和生成Modify and build

可以继续使用 Visual Studio 为 HDInsight 生成 .NET 解决方案。You can continue to use Visual Studio to build your .NET solutions for HDInsight. 但必须确保将项目配置为使用 .NET Framework 4.5。However, you must ensure that the project is configured to use .NET Framework 4.5.

部署和测试Deploy and test

使用 .NET Portability Analyzer 或手动分析提供的建议修改解决方案后,必须通过 HDInsight 测试该解决方案。Once you have modified your solution using the recommendations from the .NET Portability Analyzer or from a manual analysis, you must test it with HDInsight. 在基于 Linux 的 HDInsight 群集上测试解决方案可能会揭露一些需要更正的细小问题。Testing the solution on a Linux-based HDInsight cluster may reveal subtle problems that need to be corrected. 我们建议在测试时,在应用程序中启用其他日志记录。We recommend that you enable additional logging in your application while testing it.

有关访问日志的详细信息,请参阅以下文档:For more information on accessing logs, see the following documents:

后续步骤Next steps