I'm trying to create a class library and it needs to include System.Windows.Forms, including a bunch of other packages. It's not automatically included in the project for some reason, so I figured I could just add it. When I go to add a reference to the project, there's nothing available. In past prjects, there has been a big list of available references in the Reference Manager. Am I missing something huge here? Thanks
CodePudding user response:
Start again. You created the wrong project type to start with. This is what you want:
Note that, once you've created a project using the appropriate template, you can examine the differences between that and a regular Class Library project. For the record, here's the project file for the former:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
and here's the project file for the latter:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
If you check out the dependencies for each, you'll see that the former includes the Microsoft.WindowsDesktop.App.WindowsForms
framework that the latter lacks.