I have an existing winform app which didn’t use Program.cs. I wanted to add Program.cs with the usual code
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
but I have the error message
Application doesn’t exist in the current context.
How to solve this ?
You need to have a
usingdirective forSystem.Windows.Formsin the beginning of the file:Either that, or modify the
Mainmethod to use the full type names:…though I would recommend the first solution.