Using Clipboard in .NET 7.0
As a very occasional and self-taught programmer, I've written apps under .NET Framework 4.7.2. To use the statement
Dim text as String = Clipboard.GetText()
under that framework it's necessary to include the statement: Imports System.Windows.Forms
When I try to write an app under .NET 7.0 with the same Clipboard statement as above I get an error message saying Clipboard is not declared, with a potential fix being
Imports System.Windows.Forms (from System.Windows.Forms)
When I try to apply the recommended fix, nothing happens. If I manually insert Imports System.Windows.Forms I get a message saying the statement is unnecessary. And in any case it doesn't fix the problem. Unlike with .NET 4.7.2, System.Windows.Forms is not listed under References/General.
I'm obviously missing something fundamental. How can I use the Clipboard under 7.0? Thanks.
Re: Using Clipboard in .NET 7.0
Re: Using Clipboard in .NET 7.0
Thanks for the suggestion. I tried
Code:
Dim text as String = My.computer.clipboard.gettext()
and still get an error message,
Code:
'computer' is not a member of 'Test.My'
(where "Test" is the name of the app). Note the absence of capitalization showing key words are not being recognized.
Re: Using Clipboard in .NET 7.0
Re: Using Clipboard in .NET 7.0
Quote:
Originally Posted by
coffent
As a very occasional and self-taught programmer, I've written apps under .NET Framework 4.7.2. To use the statement
Dim text as String = Clipboard.GetText()
under that framework it's necessary to include the statement: Imports System.Windows.Forms
When I try to write an app under .NET 7.0 with the same Clipboard statement as above I get an error message saying Clipboard is not declared, with a potential fix being
Imports System.Windows.Forms (from System.Windows.Forms)
When I try to apply the recommended fix, nothing happens. If I manually insert Imports System.Windows.Forms I get a message saying the statement is unnecessary. And in any case it doesn't fix the problem. Unlike with .NET 4.7.2, System.Windows.Forms is not listed under References/General.
I'm obviously missing something fundamental. How can I use the Clipboard under 7.0? Thanks.
Did you create a Windows Desktop app? If so then you original code should work, certainly did when I just tried it.
Re: Using Clipboard in .NET 7.0
Of course! I was creating the project as a Console App, not a Console App (.NET Framework). When I switched to the latter, everything worked fine. Dumb mistake! Thanks all for your help.
Re: Using Clipboard in .NET 7.0
Quote:
Originally Posted by
coffent
Of course! I was creating the project as a Console App, not a Console App (.NET Framework). When I switched to the latter, everything worked fine. Dumb mistake! Thanks all for your help.
NET Framework is used to create Windows desktop and server-based applications. This includes ASP.NET web applications. On the other hand, . NET Core is used to create server applications that run on Windows, Linux and Mac. There is no simple method of accessing the clipboard in .net core