Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipboard.SetDataObject method regression in .NET 9.0.100-rc.2 #10049

Open
akhromushkin opened this issue Nov 11, 2024 · 5 comments
Open

Clipboard.SetDataObject method regression in .NET 9.0.100-rc.2 #10049

akhromushkin opened this issue Nov 11, 2024 · 5 comments
Assignees
Labels
regression status: This issue is a regression from a previous build or release

Comments

@akhromushkin
Copy link

Description

Clipboard.SetDataObject method doesn't place a custom DataObject into the clipboard.

Reproduction Steps

  1. Create a .NET Framework WinForms (or WPF) project.
  2. Create a custom DataObject class descendant:
    public class SomeDataObject : DataObject {
        public static string Format = "SomeDataObjectId";
        public override string[] GetFormats() {
            return new string[] { Format };
        }
    }
  1. Call the Clipboard.SetDataObject(new SomeDataObject()); method to add the SomeDataObject's class instance into the clipboard.

Expected behavior

SomeDataObject is added into the clipboard

Image

And Clipboard.GetDataObject().GetDataPresent(SomeDataObject.Format) is true

Actual behavior

The clipboard doesn't contain the SomeDataObject instance

Image

And Clipboard.GetDataObject().GetDataPresent(SomeDataObject.Format) is false

Regression?

Yes, in .NET 8 everything works.

Known Workarounds

No response

Impact

No response

Configuration

$ dotnet --info
.NET SDK:
 Version:           9.0.100-rc.2.24474.11
 Commit:            315e1305db
 Workload version:  9.0.100-manifests.4872d5d5
 MSBuild version:   17.12.0-preview-24473-03+fea15fbd1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100-rc.2.24474.11\

Host:
  Version:      9.0.0-rc.2.24473.5
  Architecture: x64
  Commit:       990ebf52fc

.NET SDKs installed:
  9.0.100-rc.2.24474.11 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-rc.2.24473.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 9.0.0-rc.2.24474.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other information

No response

@miloush
Copy link
Contributor

miloush commented Nov 11, 2024

Please include a repro project. This seems like an unusual way to use data objects. Perhaps the regression is because of the binary formatter removal? https://devblogs.microsoft.com/dotnet/binaryformatter-removed-from-dotnet-9/.

@Kuldeep-MS
Copy link
Member

@akhromushkin After following your reproduction steps, I encountered the error shown below. Could you please provide more detailed steps?
Image

@akhromushkin
Copy link
Author

Perhaps is more related to WinForms. So I have attached several projects:
Issue_10049_WPF.zip
Issue_10049_WinForms.zip

@harshit7962 harshit7962 added the regression status: This issue is a regression from a previous build or release label Nov 13, 2024
@BlueBSH
Copy link

BlueBSH commented Nov 21, 2024

This issue still exists in the RTM GA version of .NET9.0.0

@miloush
Copy link
Contributor

miloush commented Nov 21, 2024

This is all Winforms classes and should be moved to the Winforms repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression status: This issue is a regression from a previous build or release
Projects
None yet
Development

No branches or pull requests

5 participants