Windows Forms obsoletions (.NET 10)

Some Windows Forms APIs have been marked as obsolete, starting in .NET 10.

Previous behavior

In previous .NET versions, these APIs can be used without any build warning.

New behavior

In .NET 10 and later versions, use of these APIs produces a compile-time warning with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the warnings individually instead of blanket-suppressing all obsoletion warnings.

The following table lists the custom diagnostic IDs and their corresponding warning messages.

Diagnostic ID Description Severity Version introduced
WFDEV004 Form.OnClosing(CancelEventArgs), Form.OnClosed(EventArgs) and the corresponding events are obsolete. Use Form.OnFormClosing(FormClosingEventArgs), Form.OnFormClosed(FormClosedEventArgs), Form.FormClosing and Form.FormClosed instead. Warning Preview 1
WFDEV005 Clipboard.GetData(String) method is obsolete. Use Clipboard.TryGetData methods instead. Warning Preview 1
WFDEV006 ContextMenu, DataGrid, MainMenu, Menu, StatusBar, ToolBar are obsolete. They're provided for binary compatibility with .NET Framework. Warning Preview 1

Version introduced

.NET 10

Type of breaking change

These obsoletion warnings can affect source compatibility.

  • Follow the specific guidance provided for the each diagnostic ID using the URL link provided on the warning.
  • If necessary, you can suppress the warning using the custom WFDEVxxx diagnostic ID value.

Affected APIs

WFDEV004

WFDEV005

WFDEV006

See also