VS Code 中的 System.Windows.Forms 程序集引用

Tim*_*cta 4 c# visual-studio-code

为了在 Visual Studio Code 中设置我的 C# 开发框架,我想使用System.Windows.Forms引用来设置一个窗口。

代码:

using System;
using System.Collections;
using System.Windows.Forms;
namespace Softwaredevelopment
{
   public partial class Form1 : Form
   {
      public Form1()
      {
        //tbd
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

我收到错误:

缺少装配参考。

我必须在project.json文件或.csproj文件中添加什么才能获得创建窗口的能力。

kil*_*98q 5

想通了,您可以将其添加到您的 .csproj 您还可以在此处找到名称和版本 C:\Windows\Assembly

  <Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <TargetFramework>net452</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Drawing-dotnet-core" Version="1.2.3"/>

    <Reference Include="System.Windows.Forms" version="2.0.0.0" /> //< ----- add This line here

  </ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)