Click here to Skip to main content
14,580,625 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to write a button program in visual studio 2019 which I have just installed.

I am getting following error:

The type or namespace name 'Forms' does not exist in the namespace 'System.Windows'(are you missing an assembly reference)

My code is as follows:
using System;
using System.Drawing;
using System.Windows.Forms;//this line is giving error
namespace Button1
    class Program
        static void Main(string[] args)
            Console.WriteLine("Hello World!");

What I have tried:

Nothing, this is my first try.
Updated 25-Aug-19 18:45pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You chose to create a Console Application Project: you cannot use WinForm Controls, or any other Controls, in a Console App: it is limited to a single Window with text input directly via keyboard or paste.

Instead, create a new Windows Forms Project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100