Repository navigation
[release/11.0] Fix providing EnhancedMetafile to other applications through the clipboard - #12059
Open
Shyam-Gupta wants to merge 1 commit into
Open
Shyam-Gupta wants to merge 1 commit into
Shyam-Gupta wants to merge 1 commit into
Conversation
…board The shared OLE code in System.Private.Windows.Core only accepts TYMED_HGLOBAL, TYMED_ISTREAM and TYMED_GDI, so every request for CF_ENHMETAFILE (always TYMED_ENHMF) fails before WPF's handler runs. - Add WpfOleServices.AllowedTymeds, which also allows TYMED_ENHMF. It implements IOleServices.AllowedTymeds once the companion dotnet/winforms change flows in, and must be in place before then. - Fix the TYMED_ENHMF branch of WpfOleServices.GetDataHere, which never assigned the handle created from a MemoryStream and returned S_OK with a null handle. It now sets tymed and hEnhMetaFile, and returns E_FAIL when there is no handle, as .NET 9 did. - Add a clipboard test that reads the EMF back the way another application would. It is skipped until the winforms change flows in. Fixes #11986 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Backport-of: #11988 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0894b2bd-53a0-4ca6-ad0c-b04194aff537
Contributor
|
Hi @Shyam-Gupta. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge. To learn more about how to prepare a servicing PR click here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11986
Depends on corresponding WinForms side of changes: dotnet/winforms#15328
This PR has to merge before that change flows into WPF, or WPF won't build.
Description
On .NET 10, the shared OLE code in System.Private.Windows.Core rejects every
TYMED_ENHMFrequest withDV_E_TYMED, so WPF can't provideCF_ENHMETAFILEto other applications even though the format is still advertised.WpfOleServices.AllowedTymeds, which also allowsTYMED_ENHMF. It implements the newIOleServices.AllowedTymedsfrom dotnet/winforms#TBD.TYMED_ENHMFbranch ofWpfOleServices.GetDataHere, which was unreachable until now. For aMemoryStreamit never assigned the handle to the medium, so it returnedS_OKwith a null handle. It now setstymedandhEnhMetaFile, and returnsE_FAILwhen there is no handle, as .NET 9 did.GetClipboardData, the way another application would. It's skipped until the winforms change flows in.I'd like to request a backport to
release/10.0after this merges.Customer Impact
EMF that WPF apps put on the clipboard can't be pasted into other applications, for example Word's Paste Special → Picture (Enhanced Metafile). It fails silently, and there's no workaround.
Regression
Yes. It works on .NET 9 and is broken on .NET 10.
Testing
build.cmd -packsucceeds, both against the currentMicrosoft.Private.Winformspackage and against a local build of Let each platform declare the TYMEDs it supports so WPF can provide enhanced metafiles winforms#15218.copy: trueandcopy: false.GetClipboardData(CF_ENHMETAFILE)and OLEGetData, for delayed and flushed data. The unpatched runtime fails all three checks.Risk
Low. It only affects
TYMED_ENHMFrequests forEnhancedMetafiledata, which always fail today, and restores the .NET 9 behavior.Microsoft Reviewers: Open in CodeFlow