Forum Discussion

KenB-LA's avatar
KenB-LA
Copper Contributor
Dec 08, 2021

Clipboard class in .Net 6

I am upgrading some code from .Net Framework 4.62 to .Net 6.  I use the Clipboard Class in System.Windows.Forms.  In .Net 6 this is no longer supported.

 

is there a different namespace where Clipboard has been moved?  

  • KenB-LA's avatar
    KenB-LA
    Copper Contributor

    My bad...
    I was able to access Clipboard after adding the following line to my csproj file, in the PropertyGroup element:

       <UseWindowsForms>true</UseWindowsForms>.

     

    So the PropertyGroup tag looks like this:

     

       <PropertyGroup>
          <TargetFramework>net6.0-windows</TargetFramework>
          <UseWindowsForms>true</UseWindowsForms>
          <IsPackable>false</IsPackable>
       </PropertyGroup>


     

     

     

     

    KenB-LA 

    • SilentKnightER's avatar
      SilentKnightER
      Copper Contributor

      KenB-LA I have tried that solution, to no avail. My configuration file looks like :

       

      <PropertyGroup>
      <OutputType>Exe</OutputType>
      <TargetFramework>net6.0</TargetFramework>
      <UseWindowsForms>true</UseWindowsForms>
      <ImplicitUsings>enable</ImplicitUsings>
      <Nullable>enable</Nullable>
      <EnforceCodeStyleInBuild>False</EnforceCodeStyleInBuild>
      </PropertyGroup>

      • KenB-LA's avatar
        KenB-LA
        Copper Contributor

        SilentKnightER 

        Try changing the target framework to:
        <TargetFramework>net6.0-windows</TargetFramework>

Resources