What’s new in .NET Framework 4.7.2

Saurabh Srivastava
3 min readMay 28, 2018

--

Microsoft recently released another version of .NET Framework which is 4.7.2. This new version is already integrated in the Windows 10 April 2018 update release. If you run an older version of windows, you may download and install the new version to update the framework to the latest version or you can download the offline installer from Microsoft website.

Image source : https://cdn.windowsreport.com

In this blog, I will tell you about newly enhancements introduced in .NET Framework 4.7.2. So here are some key highlights:

1. Support for Same Site Cookies

Same site prevents a browser from sending a cookie along with a Cross-site request. The goal of the Same Site attribute is to minimize the risk of information leakage and prevent cross-site forgery attacks. The framework adds the new property SameSite to the HttpCookie (HttpCookie.SameSite) whose value is in form of enum as SameSiteMode. If the value is SameSiteMode.Strict orSameSiteMode.Lax, ASP.NET adds the same site attribute to the set-cookieheader.

You can also configure Same Site cookies at the application level by slightly modifying the web.config file as:

<system.web>

<httpCookies sameSite=”Strict” />

</system.web>

2. Support for Dependency Injection in ASP.NET Web Forms

Dependency injection lets one object supply dependencies of another object so that an object’s code need not to be changed just because a dependency has changed. It makes an application loosely coupled. .NET Framework 4.7.2 makes it easier to use this functionality in ASP.NET Web Forms now. By developing ASP.NET Applications targeting .net framework 4.7.2 you can:

1. Use setter-based, interface-based, and constructor-based injection in handlers & modules, Page instances and user controls of ASP.NET web application projects.

2. Plug in different dependency injection frameworks like NUnit as well.

3. Support for Azure Active Directory Universal Authentication & Multi-Factor Authentication

In order to improve security & compliance for Azure, this framework also introduced the Universal & Multi-Factor Authentication Scheme by using Azure Active Directory via an interactive authentication keyword. It extended SqlClient connection strings by adding a new value, Azure AD Authentication, for the existing Authentication keyword to support MFA and Azure AD Authentication. With the new SqlAuthenticationMethod.ActiveDirectoryInteractive option, SQL connectivity supports MFA as well as existing authentication methods (password & integrated authentication), which allows users to enter passwords interactively without persisting passwords in the connection string.

4. Enhancements in ClickOnce

ClickOnce is a technology by using which HDPI-aware applications for Windows Forms, Windows Presentation Foundation (WPF), and Visual Studio Tools for Office (VSTO) can all be deployed. Deployment will succeed under .NET Framework 4.7.2, if following entry is found in the application manifest file:

<windowsSettings>

<dpiAware xmlns=”http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>

</windowsSettings>

5. Additional Standard Collection APIs in Base Class Library (BCL)

.NET Framework 4.7.2 added a few APIs to the standard Collection types that will enable new functionality as follows:

  1. TryGetValue is added to SortedSet and HashSet to match the try pattern used in other collection types.
  2. The Enumerable.To* extension methods are added to SortedSet and HashSet.
  3. New HashSet constructors allow HashSets to be constructed with a capacity, offering a performance benefit when you know ahead of time what the size of the HashSet will be.

The New Standard Collection APIs are listed below:

public bool SortedSet.TryGetValue(T equalValue, out T actualValue);

public bool HashSet.TryGetValue(T equalValue, out T actualValue);

public static HashSet<TSource> ToHashSet<TSource>(this IEnumerable<TSource> source);

public static HashSet<TSource> ToHashSet<TSource>(this IEnumerable<TSource> source, IEqualityComparer<TSource> comparer);

public HashSet(int capacity);

public HashSet(int capacity, IEqualityComparer<T> comparer);

The .NET Framework 4.7.2 also includes new overloads of the GetOrAdd and AddOrUpdate methods in ConcurrentDictionary<Tkey, TValue> class to retrieve a value from the dictionary or to add it if it is not found, and to add a value to the dictionary or to update it if it is already exists. Here is the list:

public TValue AddOrUpdate<TArg>(TKey key, Func<TKey, TArg, TValue> addValueFactory,Func<TKey, TValue, TArg, TValue> updateValueFactory, TArg factoryArgument)

public TValue GetOrAdd<TArg>(TKey key, Func<TKey, TArg, TValue> valueFactory, TArg factoryArgument)

6. Some other enhancements

  1. Now the creation of RSA and DSA objects and calling ImportParameters would be simple in cryptographic improvements comes with 4.7.2.
  2. Some diagnostics improvements in WPF.
  3. By utilizing a native implementation of Zip via Zlib decompression, throughput for decompressing Zip archives has been improved.

At the end, I would like to know your views about the latest version of .NET Framework introduced by Microsoft. Please do share your views as well in the comment section of this blog post.

Thank you and happy coding!!!

--

--

Saurabh Srivastava

Software Consultant, Passionate Software Engineer, Tech enthusiast, nature & dog lover, wanderlust, love to explore & learn new technologies.