3

According to this the "Clipboard" class should be available in .Net Core 3.1 in the "System.Windows" namespace.

However in my .Net Core 3.1 project when using System.Windows.Clipboard or

using System.Windows;

void Method()
{
    Clipboard
}

in both cases I get an error saying "The type or namespace 'Clipboard', etc.".

I don't understand how to use the Clipboard class from the linked MSDN page in my .Net Core 3.1 application.

EDIT:
My question isn't answered by the linked question but by this answer (whose question is linked in the linked question, lol): https://stackoverflow.com/a/59759631/14340444

Quantum
  • 31
  • 4
  • Note the *Assembly: PresentationCore.dll*, indicating that you need to reference that assembly (or, it looks like based on other comments/answers, use an Sdk which does so for you). – Joe Sewell Sep 25 '20 at 13:53
  • @JoeSewell, huh, how do I reference that assembly? – Quantum Sep 25 '20 at 15:10
  • Well in this case it looks like you automatically reference it when your project file is set to use WPF. But in general, the *Assembly* line in the docs indicates which assembly contains the type, and you'll have to [reference it](https://learn.microsoft.com/en-us/dotnet/standard/assembly/#add-a-reference-to-an-assembly). Unfortunately, the docs don't always say where that assembly is (e.g. what NuGet package it's in, or if it's on the system somewhere) but you can at least search the assembly name for help online instead of the type. – Joe Sewell Sep 25 '20 at 15:59
  • @JoeSewell, domo arigato, koza i mas! :) – Quantum Sep 25 '20 at 16:45

1 Answers1

0

You should specifie which SDK to use in the .csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  ...
</Project>
Daniel Jo
  • 340
  • 2
  • 14