|
| 1 | +--- |
| 2 | +title: "Breaking change: .NET 10 obsoletions in Windows Forms" |
| 3 | +titleSuffix: "" |
| 4 | +description: Learn about the .NET 10 breaking change where some Windows Forms APIs have been marked as obsolete. |
| 5 | +ms.date: 03/10/2025 |
| 6 | +--- |
| 7 | +# Windows Forms obsoletions (.NET 10) |
| 8 | + |
| 9 | +Some Windows Forms APIs have been marked as obsolete, starting in .NET 10. |
| 10 | + |
| 11 | +## Previous behavior |
| 12 | + |
| 13 | +In previous .NET versions, these APIs can be used without any build warning. |
| 14 | + |
| 15 | +## New behavior |
| 16 | + |
| 17 | +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. |
| 18 | + |
| 19 | +The following table lists the custom diagnostic IDs and their corresponding warning messages. |
| 20 | + |
| 21 | +| Diagnostic ID | Description | Severity | Version introduced | |
| 22 | +| - | - | |
| 23 | +| [WFDEV004](/dotnet/desktop/winforms/wfdev-diagnostics/wfdev004) | <xref:System.Windows.Forms.Form.OnClosing(System.ComponentModel.CancelEventArgs)?displayProperty=nameWithType>, <xref:System.Windows.Forms.Form.OnClosed(System.EventArgs)?displayProperty=nameWithType> and the corresponding events are obsolete. Use <xref:System.Windows.Forms.Form.OnFormClosing(System.Windows.Forms.FormClosingEventArgs)?displayProperty=nameWithType>, <xref:System.Windows.Forms.Form.OnFormClosed(System.Windows.Forms.FormClosedEventArgs)?displayProperty=nameWithType>, <xref:System.Windows.Forms.Form.FormClosing?displayProperty=nameWithType> and <xref:System.Windows.Forms.Form.FormClosed?displayProperty=nameWithType> instead. | Warning | Preview 1 | |
| 24 | +| [WFDEV005](/dotnet/desktop/winforms/wfdev-diagnostics/wfdev005) | <xref:System.Windows.Clipboard.GetData(System.String)?displayProperty=nameWithType> method is obsolete. Use <xref:System.Windows.Forms.Clipboard.TryGetData*?displayProperty=nameWithType> methods instead. | Warning | Preview 1 | |
| 25 | +| [WFDEV006](/dotnet/desktop/winforms/wfdev-diagnostics/wfdev006) | <xref:System.Windows.Forms.ContextMenu>, <xref:System.Windows.Forms.DataGrid>, <xref:System.Windows.Forms.MainMenu>, <xref:System.Windows.Forms.Menu>, <xref:System.Windows.Forms.StatusBar>, <xref:System.Windows.Forms.ToolBar> are obsolete. They're provided for binary compatibility with .NET Framework. | Warning | Preview 1 | |
| 26 | + |
| 27 | +## Version introduced |
| 28 | + |
| 29 | +.NET 10 |
| 30 | + |
| 31 | +## Type of breaking change |
| 32 | + |
| 33 | +These obsoletion warnings can affect [source compatibility](../../categories.md#source-compatibility). |
| 34 | + |
| 35 | +## Recommended action |
| 36 | + |
| 37 | +- Follow the specific guidance provided for the each diagnostic ID using the URL link provided on the warning. |
| 38 | +- If necessary, you can suppress the warning using the custom `WFDEVxxx` diagnostic ID value. |
| 39 | + |
| 40 | +## Affected APIs |
| 41 | + |
| 42 | +### WFDEV004 |
| 43 | + |
| 44 | +- <xref:System.Windows.Forms.Form.OnClosing(System.ComponentModel.CancelEventArgs)> |
| 45 | +- <xref:System.Windows.Forms.Form.OnClosed(System.EventArgs)?displayProperty=fullName> |
| 46 | + |
| 47 | +### WFDEV005 |
| 48 | + |
| 49 | +- <xref:System.Windows.Clipboard.GetData(System.String)?displayProperty=fullName> |
| 50 | + |
| 51 | +### WFDEV006 |
| 52 | + |
| 53 | +- <xref:System.Windows.Forms.ContextMenu?displayProperty=fullName> |
| 54 | +- <xref:System.Windows.Forms.DataGrid?displayProperty=fullName> |
| 55 | +- <xref:System.Windows.Forms.MainMenu?displayProperty=fullName> |
| 56 | +- <xref:System.Windows.Forms.Menu?displayProperty=fullName> |
| 57 | +- <xref:System.Windows.Forms.StatusBar?displayProperty=fullName> |
| 58 | +- <xref:System.Windows.Forms.ToolBar?displayProperty=fullName> |
| 59 | + |
| 60 | +## See also |
| 61 | + |
| 62 | +- [Obsolete Windows Forms features in .NET 10+](/dotnet/desktop/winforms/wfdev-diagnostics/obsoletions-overview) |
0 commit comments