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 the same namespace and public partial class name so the methods could be inter-operable.
My header look like this in four files, including my main core file that calls:
public shell() { InitializeComponent(); }
Header area of .cs files that work with the UI (and seem to be causing this new conflict):
using System; using System.Windows.Forms; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.IO; using System.Data.SqlServerCe; using System.Diagnostics; using System.Threading; using System.Collections.Specialized; using System.Net; using System.Runtime.InteropServices; using watin = WatiN.Core; using WatiN.Core.Native.InternetExplorer; using System.Web; namespace WindowsFormsApplication1 { public partial class shell : Form {
Now when I try to debug/preview my application (BTW this is a Windows Application within Visual Studio 2010 Express) I get this error message:
Does not contain a static 'main' method suitable for an entry point
I looked in the application properties in Application->Startup object, but it offers me no options. How can I inform the application to begin at the .cs file that has my InitializeComponent(); command?
I'm still very new and this is my first attempt at an organizing method with c# code.
A main method is static since it is available to run when the C# program starts. It is the entry point of the program and runs without even creating an instance of the class.
The Main method is the entry point of a C# application. (Libraries and services do not require a Main method as an entry point.) When the application is started, the Main method is the first method that is invoked. There can only be one entry point in a C# program.
I was looking at this issue as well, and in my case the solution was too easy. I added a new empty project to the solution. The newly added project is automatically set as a console application. But since the project added was a 'empty' project, no Program.cs existed in that new project. (As expected)
All I needed to do was change the output type of the project properties to Class library
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With