Skip to content

Fixes issue 14400: Pasting controls via CommandSet.OnMenuPaste stopped working when hosting the WinForms designer#14403

Open
LeafShi1 wants to merge 1 commit intodotnet:mainfrom
LeafShi1:Fix_14400_restore_dragClient_CommandSet.OnMenuPaste
Open

Fixes issue 14400: Pasting controls via CommandSet.OnMenuPaste stopped working when hosting the WinForms designer#14403
LeafShi1 wants to merge 1 commit intodotnet:mainfrom
LeafShi1:Fix_14400_restore_dragClient_CommandSet.OnMenuPaste

Conversation

@LeafShi1
Copy link
Member

@LeafShi1 LeafShi1 commented Mar 17, 2026

Fixes #14400

Root cause

The logic of dragClient=true was accidentally deleted in Commit commit 5978f22,
image

This resulted in the local flag dragClient remaining false within the OnMenuPaste method—even when an IOleDragClient designer had been successfully located. As a result, the entire paste path guarded by if (dragClient) was never executed

Proposed changes

  • In CommandSet.OnMenuPaste, when an IOleDragClient designer is found, dragClient is simultaneously set to true, thereby restoring the behavior of adding controls via the Paste command within a managed designer.

Customer Impact

  • Hosting applications that embed the WinForms designer (for example via DesignSurface and IMenuCommandService.GlobalInvoke(StandardCommands.Paste)) cannot paste controls after upgrading from .NET 8 to .NET 10, breaking existing design-time workflows until this fix is applied.

Regression?

  • Yes

Risk

  • Low
Microsoft Reviewers: Open in CodeFlow

…d working when hosting the WinForms designer
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes WinForms designer Paste handling by correctly recognizing when the paste target is an IOleDragClient found via the ITreeDesigner chain, ensuring the paste logic executes for that scenario.

Changes:

  • Set dragClient = true when an IOleDragClient is discovered while walking the ITreeDesigner hierarchy during OnMenuPaste.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CommandSet.OnMenuPaste - dragClient is always false

2 participants