Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
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.
Posted
Updated 25-Aug-19 18:45pm

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900