The code "kind of works", but there other I/O problems, which may be Stack Overflow questions.
The troubling problem is Program.cs calls the Clipboard class, which is a System.Windows.Forms assembly. The project let's me add this .NET 4.7.2 assembly to the .NET 6.0 based project without compilation errors. One also needs to apply the suggestion here https://techcommunity.microsoft.com/t5/app-development/clipboard-class-in-net-6/m-p/3034107 to generate functional code.
The better solution is the find an alternative to the Clipboard class that works with .NET 6.0 natively. Any suggestions?
The troubling problem is Program.cs calls the Clipboard class, which is a System.Windows.Forms assembly. The project let's me add this .NET 4.7.2 assembly to the .NET 6.0 based project without compilation errors. One also needs to apply the suggestion here https://techcommunity.microsoft.com/t5/app-development/clipboard-class-in-net-6/m-p/3034107 to generate functional code.
The better solution is the find an alternative to the Clipboard class that works with .NET 6.0 natively. Any suggestions?
Rename
To include Windows Forms be sure to modify your Project File as follows:
Yes, it's not enough just to reference the System.Windows.Forms assembly. One needs to edit the *.csproj file and add that line as well. I wish there was simply a way to support the Clipboard via .NET 6.0, but perhaps Microsoft thinks the Clipboard is too Windows oriented to include support for it in .NET 6.0. If so, they could have said that.
Thanks for your help.
Thanks for your help.
Apparently, a lot of articles point to this as a solution:
https://github.com/CopyText/TextCopy
https://github.com/CopyText/TextCopy
Just curious how you concluded that the Clipboard was only accessible in Windows Forms? The Clipboard object we're using is defined in Windows.System ...
Thank you both for your suggestions. The TextCopy approach is more powerful (async I/O) than what I really need. I'll research the System.Windows.Clipboard approach more. Funny that alternative didn't show up in Stack Overflow.
I would prefer to avoid System.Windows.Forms, which would create an extra memory footprint.
UPDATE:
The VS Object Browser can only find System.Windows.Clipboard in .NET 4.X. If I build the project for .NET 6.0, there's no System.Windows.Clipboard found. What am I doing wrong? (I'm using Windows 7.)
I would prefer to avoid System.Windows.Forms, which would create an extra memory footprint.
UPDATE:
The VS Object Browser can only find System.Windows.Clipboard in .NET 4.X. If I build the project for .NET 6.0, there's no System.Windows.Clipboard found. What am I doing wrong? (I'm using Windows 7.)
Your Response
Post
Edit Post
Login is required