Muokkaa

Jaa


Mitigation: Custom IMessageFilter.PreFilterMessage Implementations

In Windows Forms apps that target versions of the .NET Framework starting with the .NET Framework 4.6.1, a custom IMessageFilter.PreFilterMessage implementation can safely filter messages when the Application.FilterMessage method is called if the IMessageFilter.PreFilterMessage implementation:

Impact

This change only affects Windows Forms apps that target versions of the .NET Framework starting with the .NET Framework 4.6.1.

For Windows Forms apps that target previous versions of the .NET Framework, such implementations in some cases throw an IndexOutOfRangeException exception when the Application.FilterMessage method is called

Mitigation

If this change is undesirable, apps that target the .NET Framework 4.6.1 or a later version can opt out of it by adding the following configuration setting to the <runtime> section of the app’s configuration file:

<runtime>
    <AppContextSwitchOverrides value="Switch.System.Windows.Forms.DontSupportReentrantFilterMessage=true" />
</runtime>

In addition, apps that target previous versions of the .NET Framework but are running under the .NET Framework 4.6.1 or a later version can opt in to this behavior by adding the following configuration setting to the <runtime> section of the app’s configuration file:

<runtime>
    <AppContextSwitchOverrides value="Switch.System.Windows.Forms.DontSupportReentrantFilterMessage=false" />
</runtime>

See also