Released .NET Core 2.2. What's new? (1 of 3)

Original author: Rich Lander
  • Transfer

On December 4, .NET Core 2.2 was released. “Who can be surprised by the news of a week ago?” - you ask and you will be right ... and by the way, have you already updated? )

Now in the case. The new release includes diagnostic improvements in runtime, ARM32 support for Windows, and support for the Azure Active Directory for the SQL Client. The biggest improvements to this release are the ASP.NET Core.

On the same day, ASP.NET Core 2.2 and Entity Framework Core 2.2 were released.

.NET Core 2.2 for Windows, macOS and Linux are already waiting for you on the links:

.NET Core 2.2 support is present in Visual Studio 15.9 , Visual Studio for Mac and Visual Studio Code.

Docker containers are available at microsoft / dotnet for both .NET Core and ASP.NET Core.

The most complete information on this release can be found in .NET Core 2.2 release notes . There are additional instructions, known problems and ways to get around them. Please let us know about any shortcomings found in this document in the comments to dotnet / core # 2098 .

Tiered compilation

Multi-level compilation is a feature that allows runtime to more intelligently use the JIT compiler to achieve better performance both at the stage of launching the application and at the stage of maximizing performance during its operation. The ability to do this was added as an optional feature in .NET Core 2.1, and subsequently turned on by default in .NET Core 2.2 Preview 2. We thought and decided that we were still not sure whether its inclusion in the final release of .NET Core 2.2 was meaningful, so again made it optional, just like it was in .NET Core 2.1. However, in .NET Core 3.0 we are going to switch to it completely.

Runtime events

It usually makes sense to monitor runtime services, for example, GC, JIT or ThreadPool of the current process, in order to understand how these services behave along the life of the application. On Windows systems, this is typically done using ETW and monitoring ETW events for the current process. This method still works fine, but using ETW is not always possible, and when it is possible it can be difficult. For example, you are running in an environment with insufficient privilege or on Linux / macOS.

Starting with .NET Core 2.2, CoreCLR events can be handled by a class EventListener. These events describe the behavior of GC, JIT, ThreadPool and Interop. These are the same events that are now available as part of the CoreCLR ETW provider for Windows. This approach allows applications to process events or use transport mechanisms to send events to the telemetry aggregation service.

This is how you can subscribe to events:

internalsealedclassSimpleEventListener : EventListener
      // Вызывается в момент создания EventSource.protectedoverridevoidOnEventSourceCreated(EventSource eventSource)
          // Смотрим за EventSource для .NET runtime и подключаем весь список событий.if (eventSource.Name.Equals("Microsoft-Windows-DotNETRuntime"))
                  EnableEvents(eventSource, EventLevel.Verbose, (EventKeywords)(-1));
      // Вызывается в момент регистрации события.protectedoverridevoidOnEventWritten(EventWrittenEventArgs eventData)
          // Распечатываем содержимое события в консоль.
          Console.WriteLine($"ThreadID = {eventData.OSThreadId} ID = {eventData.EventId} Name = {eventData.EventName}");
          for (int i = 0; i < eventData.Payload.Count; i++)
              string payloadString = eventData.Payload[i] != null ? eventData.Payload[i].ToString() : string.Empty;
              Console.WriteLine($"\tName = \"{eventData.PayloadNames[i]}\" Value = \"{payloadString}\"");

AccessToken support in SqlConnection

The ADO.NET provider for SQL Server, SqlClient, now supports setting the AccessToken property, which allows authentication of connections to SQL Server using Azure Active Directory. To start using this feature, you need to get an access token using the Active Directory Authentication Library for .NET, which comes in the NuGet package of the Microsoft.IdentityModel.Clients.ActiveDirectory package.

Here's how to authenticate connections to SQL Server using Azure AD:

// получаем следующий токен, используя ADAL.NETvar authContext = new AuthenticationContext(authority);
var authResult = await authContext.AcquireTokenAsync(appUri, clientCredential);
// подключаемся к SQL Servervar sqlConnection = new SqlConnection(connectionString);
sqlConnection.AccessToken = authResult.AccessToken;
await sqlConnection.OpenAsync();

More information can be obtained from the ADAL.NET documentation and the Azure Active Directory .

Running code before executing Main

.NET Core now allows you to embed code before running the main method, and this is done using Startup Hook. These hooks allow the hosting to customize the behavior of the application after it has been deployed, without the need to rebuild or change the code.

Here we mean that hosting providers will create their own configurations and policies, including settings that can potentially affect the behavior of loading the main entry point into the application, for example, AssemblyLoadContext. A hook can be used to customize tracing or telemetry, connect callbacks, or any other behavior settings specific to a particular execution environment. Hooks are an entity completely separate with respect to the entry point and therefore do not require changing the application code.

A more detailed description is in the documentation .

Windows arm32

We are adding Windows ARM32 support, similar to the one that already exists for Linux ARM32, starting with .NET Core 2.1. Windows has been supporting WIN32 for some time, thanks to Windows IoT Core . As part of the Windows Server 2019 release, ARM32 support has been added to the Nanoserver. .NET Core can now be used on both the Nanoserver and IoT Core.

Docker Nanoserver containers for ARM32, as always, will appear in microsoft / dotnet on the Docker Hub.

We would like to publish the .NET Core assemblies for Windows ARM32 today, but we stumbled over a belated bug that makes publishing them meaningless. We hope that the assembly will appear for .NET Core 2.2.1 somewhere in January 2019.

Supported Platforms

.NET Core 2.2 is supported on the following operating systems:

  • Windows Client: 7, 8.1, 10 (1607+)
  • Windows Server: 2008 R2 SP1 +
  • macOS: 10.12+
  • RHEL: 6+
  • Fedora: 26+
  • Ubuntu: 16.04+
  • Debian: 9+
  • SLES: 12+
  • openSUSE: 42.3+
  • Alpine: 3.7+

Supported hardware platforms:

  • x64 - Windows, macOS, and Linux
  • x86 - windows
  • ARM32 - Linux (Ubuntu 16.04+, Debian 9+)
  • ARM32 - Windows (1809+; available in January)


.NET Core 2.2 is a release in which major platform improvements have appeared. We strongly recommend that you try it and tell you what you think about it. In addition, it makes sense to understand the improvements in ASP.NET Core 2.2 and Entity Framework 2.2.

Don't forget that the DotNext tickets will go up from January 1st. Personal - for a thousand, and Standard - for two thousand. Details about Early Bird - on the site .

Also popular now: