Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Windows.Forms assembly reference in VS Code

To set up my development framework for c# in visual studio code, I want to use the System.Windows.Forms refernce in order to set up a window.

Code:

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

I get the error:

Missing Assembly Reference.

What do I have to add in the project.json file or the .csproj file to get the ability to create a window.

like image 579
TimRicta Avatar asked Oct 25 '25 20:10

TimRicta


1 Answers

Figured it out you can add this to your .csproj You can also find the names and versions here 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>
like image 134
kil98q Avatar answered Oct 28 '25 11:10

kil98q