I began organizing my code to day into seperarate .cs files, and in order to allow the methods that work with the UI to continue to do so I would create the .cs code under t
If you are like me, then you might have started with a Class Library, and then switched this to a Console Application. If so, change this...
namespace ClassLibrary1
{
public class Class1
{
}
}
To this...
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
}
}
}
If you don't have a file named Program.cs
, just add a new Class and name it Program.cs
.
Then paste this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Sales {
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());
}
}
}
For me, the error was actually produced by "Feature 'async main' is not available in C# 7.0. Please use language version 7.1 or greater". This issue was resulting in the "Does not contain a static 'main' method suitable for an entry point" message in the Error List, but the Output window showed the "not available" error. To correct this, I changed the language version from 'C# latest minor version (default)' to 'C# latest minor version (latest)' under Advanced Build Settings.
<OutputType>Library</OutputType>
cheers !
Change the Output Type under the Project > Properties to that of a “Class Library”. By default, this setting may have been set to a “Console Application”.
Check to see if the project is set as the "Startup Project"
Right click on the project and choose "Set as Startup Project" from the menu.