System windows forms missing assembly reference

Can’t use System.Windows.Forms

I have tried making (my first) a C# program:

This goes well, but if I try using System.Windows.Forms:

This is the error I get:

Some details: — I am using Visual Studio 2012; — I have installed the .NET Development Kit; — It is a Console Application.

Maybe it’s because on a Console Application can’t use System.Windows.Forms? If so, what program should be? I also have tried with a form, but I was only displaying a window and no code.

8 Answers 8

A console application does not automatically add a reference to System.Windows.Forms.dll.

Right-click your project in Solution Explorer and select Add reference. and then find System.Windows.Forms and add it.

You have to add the reference of the namespace : System.Windows.Forms to your project, because for some reason it is not already added, so you can add New Reference from Visual Studio menu.

Right click on «Reference» ▶ «Add New Reference» ▶ «System.Windows.Forms»

To add the reference to «System.Windows.Forms», it seems to be a little different for Visual Studio Community 2017.

1) Go to solution explorer and select references

2) Right-click and select Add references

Читайте также:  Как записать windows с hdd
Оцените статью