Azure 云服务中的目标 .NET 4.5.2

Target .NET 4.5.2 in Azure Cloud Serice

我使用 Azure 托管云服务,并更新了我的代码以面向 .NET 4.5.2 Framework。当我发布它时,事情变得很糟糕:

The 'targetFramework' attribute in the element of the Web.config file is used only to target version 4.0 and later of the .NET Framework (for example, ''). The 'targetFramework' attribute currently references a version that is later than the installed version of the .NET Framework. Specify a valid target version of the .NET Framework, or install the required version of the .NET Framework.

这里出现了死机黄屏:

compilation strict="false" explicit="true" targetFramework="4.5.2"

所以我在这里很困惑,因为我的代码中的任何特殊功能都不需要针对 4.5.2,但 4.5 似乎 "old"。我在这里使用云服务错了吗?我继续使用 4.5 有问题吗?或者我应该通过一些步骤在发布代码时使用 4.5.2 吗?

您收到此错误的原因是默认情况下您的云服务虚拟机上未安装 .Net Framework 4.5.2。这是微软计划很快做的事情(根据微软本周早些时候发出的电子邮件)。

来自该电子邮件:

On August 7, 2014, Microsoft announced that support will end for .NET Framework 4, 4.5, and 4.5.1 on January 12, 2016. It is recommended that customers and developers complete the in-place update to .NET Framework 4.5.2 by January 12, 2016 to continue receiving technical support and security updates. Visit Microsoft .NET Framework Support Lifecycle Policy for more details. On October 27, we announced that, Azure will update the .NET Framework in Windows Azure Guest operating system (Guest OS) family 2.x, 3.x and 4.x to .NET Framework 4.5.2 in the upcoming November Guest OS Release. Since then, we have received customers’ feedback to postpone the automatic update to an OS release with .NET 4.5.2 and provide an image with .NET 4.5.2 for test validation.

To better accommodate customers’ requirements and provide a smooth upgrade to .NET 4.5.2, Azure will update the .NET Framework in Windows Azure Guest operating system (Guest OS) family 2.x, 3.x and 4.x to .NET Framework 4.5.2 in the January 2016 Guest OS Release. Cloud services running on Guest OS family 2.x, 3.x and 4.x with automatic updates enabled will be updated to the January 2016 Guest OS with .NET Framework 4.5.2. In November, the .NET Framework installed in the default OS will not be changed. In order to help customers validate their cloud service with .NET 4.5.2, Azure will provide a second set of November OS Versions 201511-02 for with .NET 4.5.2 for manual deployment.

要在您的云服务中手动安装 .Net Framework 4.5.2,您可能会发现此 link 有帮助:https://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-install-dotnet.

以防对大家有帮助。我遇到了同样的问题,我的解决方法是将 OS 从 Windows Server 2012 更新到最新的 OS(当前为 Windows Server 2016)以修复云服务问题。