To add winforms support to an .NET class (Windows only) library add <UseWindowsForms>true</UseWindowsForms> to the project file. It will look like something below. (.NET 8.0)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>