I want to use the simpliest message box in my console program( empty C# project type selected).
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Windows.Forms;
namespace roughDraft
{
class Program
{
public static void Main()
{
MessageBox.Show("Hello :)");
Console.ReadKey();
}
}
}
The type or namespace name ‘Forms’ does not exist in the namespace
‘System.Windows’ (are you missing an assembly reference?)
As you can see in this case program doesn’t work, athough I used exactly the same namespace as specified in the official documentation.
Why it’s no problem when using less specified namespace, i.e. System.Windows? How to decide whether to “cut” or not?
You need to add reference
System.Windows.Forms.dllto use that.To add the reference,follow the following step:In Solution Explorer, right-click on the project node and click Add Reference.
In the Add Reference dialog box, select the
.NETtab and chooseSystem.Windows.Formsand click OK.