简体   繁体   中英

Dumb question probably, but in .NET 6, where are all the dll's when creating a class library?

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

Reference Manager that I'm seeing

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM