Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/core/compatibility/10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
4 changes: 4 additions & 0 deletions docs/core/compatibility/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <xref:System.Windows.Controls> namespace because they did not exist in the <xref:System.Windows.Forms> namespace in .NET Core 3.1 through .NET 9.0.

```xml
<ImplicitUsings>enable</ImplicitUsings>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
```

## New behavior

The affected types in the <xref:System.Windows.Forms> namespace cause a compile-time error when there is an ambiguous reference between <xref:System.Windows.Controls> and <xref:System.Windows.Forms>.

```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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be relative link since it's in the same repo.


## Affected APIs

- <xref:System.Windows.Forms.ContextMenu?displayProperty=fullName>
- <xref:System.Windows.Forms.DataGrid?displayProperty=fullName>
- <xref:System.Windows.Forms.DataGridCell?displayProperty=fullName>
- <xref:System.Windows.Forms.Menu?displayProperty=fullName>
- <xref:System.Windows.Forms.MenuItem?displayProperty=fullName>
- <xref:System.Windows.Forms.ToolBar?displayProperty=fullName>
- <xref:System.Windows.Forms.StatusBar?displayProperty=fullName>
- <xref:System.Windows.Controls.ContextMenu?displayProperty=fullName>
- <xref:System.Windows.Controls.DataGrid?displayProperty=fullName>
- <xref:System.Windows.Controls.DataGridCell?displayProperty=fullName>
- <xref:System.Windows.Controls.Menu?displayProperty=fullName>
- <xref:System.Windows.Controls.MenuItem?displayProperty=fullName>
- <xref:System.Windows.Controls.ToolBar?displayProperty=fullName>
- `System.Windows.Controls.StatusBar`