Runtime changes for migration to .NET Framework 4.8.x
This article lists the app compatibility issues that were introduced in .NET Framework 4.8 and 4.8.1.
.NET Framework 4.8
ASP.NET
ASP.NET Fix handling of InputAttributes and LabelAttributes for WebForms CheckBox control
Details
For applications that target .NET Framework 4.7.2 and earlier versions, CheckBox.InputAttributes and CheckBox.LabelAttributes that are programmatically added to a WebForms CheckBox control are lost after postback. For applications that target .NET Framework 4.8 or later versions, they are preserved after postback.
Suggestion
For the correct behavior for restoring attributes on postback, set the targetFrameworkVersion
to 4.8 or higher. For example:
<configuration>
<system.web>
<httpRuntime targetFramework="4.8"/>
</system.web>
</configuration>
Setting it lower, or not at all, preserves the old incorrect behavior.
Name | Value |
---|---|
Scope | Unknown |
Version | 4.8 |
Type | Runtime |
Affected APIs
ASP.NET Incorrect multipart handling may result in lost form data.
Details
In applications that target .NET Framework 4.7.2 and earlier versions, ASP.NET might incorrectly parse multipart boundary values, resulting in form data being unavailable during request execution. Applications that target .NET Framework 4.8 or later versions correctly parse multipart data, so form values are available during request execution.
Suggestion
Starting with applications running on .NET Framework 4.8, when targeting .NET Framework 4.8 or later by using the targetFrameworkVersion
element, the default behavior changes to strip delimiters. When targeting previous framework versions or not using targetFrameworkVersion
, trailing delimiters for some values are still returned.
This behavior can also be explicitly controlled with an appSetting
:
<configuration>
<appSettings>
...
<add key="aspnet:UseLegacyMultiValueHeaderHandling" value="true"/>
...
</appSettings>
</configuration>
Name | Value |
---|---|
Scope | Unknown |
Version | 4.8 |
Type | Runtime |
Affected APIs
ASP.NET ValidationContext.MemberName is not NULL when using custom DataAnnotations.ValidationAttribute
Details
In .NET Framework 4.7.2 and earlier versions, when using a custom System.ComponentModel.DataAnnotations.ValidationAttribute, the ValidationContext.MemberName property returns null
. In .NET Framework 4.8 version prior to the October 2019 update, it returns the member name. Starting with .NET Framework October 2019 Preview of Quality Rollup for .NET Framework 4.8, it returns null
by default, but you can opt in to return the member name instead.
Suggestion
Add the following setting to your web.config file for the property to return the member name in .NET Framework October 2019 Preview of Quality Rollup for .NET Framework 4.8 and later versions:
<configuration>
<appSettings>
...
<add key="aspnet:GetValidationMemberName" value="true"/>
...
</appSettings>
</configuration>
In .NET Framework 4.8 version prior to the October 2019 update, adding this to your web.config file restores the previous behavior and the property returns null
.
Name | Value |
---|---|
Scope | Unknown |
Version | 4.8 |
Type | Runtime |
Affected APIs
Core
.NET COM successfully marshals ByRef SafeArray parameters on events
Details
In .NET Framework 4.7.2 and earlier versions, a ByRef SafeArray parameter on a COM event would fail to marshal back to native code. With this change, the SafeArray is now marshalled successfully.
- [ x ] Quirked
Suggestion
If properly marshalling ByRef SafeArray parameters on COM Events breaks execution, you can disable this code by adding the following configuration switch to your application config:
<appSettings>
<add key="Switch.System.Runtime.InteropServices.DoNotMarshalOutByrefSafeArrayOnInvoke" value="true" />
</appSettings>
Name | Value |
---|---|
Scope | Minor |
Version | 4.8 |
Type | Runtime |
Affected APIs
Not detectable via API analysis.
.NET Interop will now QueryInterface for IAgileObject (a WinRT interface)
Details
When using a WinRT event with a .NET delegate, Windows will QI for IAgileObject starting with .NET Framework 4.8. In previous versions of .NET Framework, the runtime would fail that QI, and the event could not be subscribed.
- [ x ] Quirked
Suggestion
If enabling the QI for IAgileObject breaks execution, you can disable this code by setting the following configuration.
Method 1: Environment variable
Set the following environment variable: COMPLUS_DisableCCWSupportIAgileObject=1
This method affects any environment that inherits this environment variable. This might be just a single console session, or it might affect the entire machine if you set the environment variable globally. The environment variable name is not case-sensitive.
Method 2: Registry
Using Registry Editor (regedit.exe), find either of the following subkeys:
- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework
- HKEY_CURRENT_USER\SOFTWARE\Microsoft.NETFramework
Then add the following entry:
Name: DisableCCWSupportIAgileObject Type: DWORD (32-bit) value (also called REG_DWORD) Data: 1
You can use the Windows REG.EXE tool to add this value from a command line or scripting environment. For example:
reg add HKLM\SOFTWARE\Microsoft.NETFramework /v DisableCCWSupportIAgileObject /t REG_DWORD /d 1
In this case, HKLM
is used instead of HKEY_LOCAL_MACHINE
. Use reg add /?
to see help on this syntax. The registry value name is not case-sensitive.
Name | Value |
---|---|
Scope | Edge |
Version | 4.8 |
Type | Runtime |
Affected APIs
Not detectable via API analysis.
Windows Communication Foundation (WCF)
svcTraceViewer ComboBox high contrast change
Details
In the Microsoft Service Trace Viewer tool, ComboBox controls were not displayed in the correct color in certain high contrast themes. The issue was fixed in .NET Framework 4.7.2. However, due to .NET Framework SDK backward compatibility requirements, the fix was not visible to customers by default. .NET 4.8 surfaces this change by adding the following AppContext configuration switches to the svcTraceViewer.exe.config file:
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false" />
Suggestion
If you don't want to have the high contrast behavior change, you can disable it by removing the following section from the svcTraceViewer.exe.config file:
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false" />
Name | Value |
---|---|
Scope | Edge |
Version | 4.8 |
Type | Runtime |
Affected APIs
Not detectable via API analysis.
Windows Presentation Foundation (WPF)
Data Binding improvement for KeyedCollection
Details
Fixed Binding incorrect use of IList indexer when the source object declares a custom indexer with the same signature (for example, KeyedCollection<int,TItem>
).
Suggestion
In order for an application that targets an older version to benefit from this change, it must run on the .NET Framework 4.8 or later, and it must opt in to the change by adding the following AppContext switch to the <runtime>
section of the app config file and setting it to false
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
</startup>
<runtime>
<!-- AppContextSwitchOverrides value attribute is in the form of key1=true/false;key2=true/false -->
<AppContextSwitchOverrides value="Switch.System.Windows.Data.Binding.IListIndexerHidesCustomIndexer=false" />
</runtime>
</configuration>
Name | Value |
---|---|
Scope | Major |
Version | 4.8 |
Type | Runtime |
Affected APIs
Not detectable via API analysis.
Fixed a issue when ListBox stops responding if it contains duplicate value-types
Details
Fixed a problem where a virtualizing ItemsControl can stop responding during scrolling when its Items
collection contains duplicate value-typed objects.
Name | Value |
---|---|
Scope | Major |
Version | 4.8 |
Type | Runtime |
Affected APIs
Not detectable via API analysis.
Improvements to Grid star-rows space allocating algorithm
Details
Fixed a bug in the algorithm for allocating sizes to) in a Grid introduced in .NET Framework 4.7. In some cases, such as a Grid with Height="Auto"
containing empty rows, rows were arranged at the wrong position, possibly outside the Grid altogether.
Suggestion
In order for the application to benefit from these changes, it must run on the .NET Framework 4.8 or later.
Name | Value |
---|---|
Scope | Major |
Version | 4.8 |
Type | Runtime |
Affected APIs
Not detectable via API analysis.
Keyboard navigation improvement in ListBox with Hyperlinks
Details
Fixed incorrect result of pressing an arrow key when the focus is on a hyperlink within an item that is not the selected item of the parent ItemsControl.
Name | Value |
---|---|
Scope | Major |
Version | 4.8 |
Type | Runtime |
Affected APIs
Not detectable via API analysis.
Performance improvement in Automation tree for grouping ItemsControls
Details
Improved the performance of rebuilding the automation tree of an ItemsControl, such as a ListBox or DataGrid, in which grouping is enabled.
Name | Value |
---|---|
Scope | Major |
Version | 4.8 |
Type | Runtime |
Affected APIs
Not detectable via API analysis.
.NET Framework 4.8.1
No app compatibility issues were introduced in .NET Framework 4.8.1.