diff --git a/docs/core/compatibility/10.0.md b/docs/core/compatibility/10.0.md index 5da792b1b23cd..bcd1db6133c36 100644 --- a/docs/core/compatibility/10.0.md +++ b/docs/core/compatibility/10.0.md @@ -54,9 +54,10 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af ## Windows Forms -| Title | Type of change | Introduced version | -|-------------------------------------------------------------------------------------------------------------------|---------------------|--------------------| -| [API obsoletions](windows-forms/10.0/obsolete-apis.md) | Source incompatible | Preview 1 | -| [Renamed parameter in HtmlElement.InsertAdjacentElement](windows-forms/10.0/insertadjacentelement-orientation.md) | Source incompatible | Preview 1 | -| [TreeView checkbox image truncation](windows-forms/10.0/treeview-text-location.md) | Behavioral change | Preview 1 | -| [StatusStrip uses System RenderMode by default](windows-forms/10.0/statusstrip-renderer.md) | Behavioral change | Preview 1 | +| Title | Type of change | Introduced version | +|-----------------------------------------------------------------------------------------------------------------------------------------------|---------------------|--------------------| +| [API obsoletions](windows-forms/10.0/obsolete-apis.md) | Source incompatible | Preview 1 | +| [Applications referencing both WPF and WinForms must disambiguate MenuItem and ContextMenu types](windows-forms/10.0/menuitem-contextmenu.md) | Source incompatible | Preview 1 | +| [Renamed parameter in HtmlElement.InsertAdjacentElement](windows-forms/10.0/insertadjacentelement-orientation.md) | Source incompatible | Preview 1 | +| [TreeView checkbox image truncation](windows-forms/10.0/treeview-text-location.md) | Behavioral change | Preview 1 | +| [StatusStrip uses System RenderMode by default](windows-forms/10.0/statusstrip-renderer.md) | Behavioral change | Preview 1 | diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index 286002fca5b30..e1555c157dea6 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -46,6 +46,8 @@ items: items: - name: API obsoletions href: windows-forms/10.0/obsolete-apis.md + - name: Applications referencing both WPF and WinForms must disambiguate MenuItem and ContextMenu types + href: windows-forms/10.0/menuitem-contextmenu.md - name: Renamed parameter in HtmlElement.InsertAdjacentElement href: windows-forms/10.0/insertadjacentelement-orientation.md - name: TreeView checkbox image truncation @@ -2128,6 +2130,8 @@ items: items: - name: API obsoletions href: windows-forms/10.0/obsolete-apis.md + - name: Applications referencing both WPF and WinForms must disambiguate MenuItem and ContextMenu types + href: windows-forms/10.0/menuitem-contextmenu.md - name: Renamed parameter in HtmlElement.InsertAdjacentElement href: windows-forms/10.0/insertadjacentelement-orientation.md - name: TreeView checkbox image truncation diff --git a/docs/core/compatibility/windows-forms/10.0/menuitem-contextmenu.md b/docs/core/compatibility/windows-forms/10.0/menuitem-contextmenu.md new file mode 100644 index 0000000000000..64d11c43e7350 --- /dev/null +++ b/docs/core/compatibility/windows-forms/10.0/menuitem-contextmenu.md @@ -0,0 +1,68 @@ +--- +title: "Breaking change - Applications referencing both WPF and WinForms must disambiguate MenuItem and ContextMenu types" +description: "Learn about the breaking change in .NET 10 Preview 1 where applications referencing both WPF and WinForms must disambiguate MenuItem and ContextMenu types." +ms.date: 3/11/2025 +ai-usage: ai-assisted +ms.custom: https://github.com/dotnet/docs/issues/44738 +--- + +# Applications referencing both WPF and WinForms must disambiguate MenuItem and ContextMenu types + +This document describes a breaking change introduced in .NET 10 Preview 1. Applications that reference both Windows Presentation Foundation (WPF) and Windows Forms (WinForms) must disambiguate certain types, such as `MenuItem` and `ContextMenu`, to avoid compile-time errors. + +## Version introduced + +.NET 10 Preview 1 + +## Previous behavior + +Previously, the types `ContextMenu`, `DataGrid`, `DataGridCell`, `Menu`, `MenuItem`, `ToolBar`, and `StatusBar` would resolve to the namespace because they did not exist in the namespace in .NET Core 3.1 through .NET 9.0. + +```xml +enable +true +true +``` + +## New behavior + +The affected types in the namespace cause a compile-time error when there is an ambiguous reference between and . + +```output +CS0104 'ContextMenu' is an ambiguous reference between 'System.Windows.Controls.ContextMenu' and 'System.Windows.Forms.ContextMenu' +``` + +## Type of breaking change + +This is a [source incompatible](../../categories.md#source-compatibility) change. + +## Reason for change + +The change facilitates migration from .NET Framework when third-party libraries cannot be updated. A .NET 10 application can continue to reference .NET Framework dependencies and handle errors at runtime. + +## Recommended action + +Use aliases to resolve conflicting namespaces. For example: + +```csharp +using ContextMenu = System.Windows.Controls.ContextMenu; +``` + +Refer to the [alias name conflicts documentation](/dotnet/csharp/language-reference/compiler-messages/using-directive-errors#alias-name-conflicts) for more details. + +## Affected APIs + +- +- +- +- +- +- +- +- +- +- +- +- +- +- `System.Windows.Controls.StatusBar`