Hello,

I am trying to debug a simple hello world program

namespace TestProject
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Function to create Message Box with
        /// with text "Hello World"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnHelloWorld_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Hello World");
        }
    }
}

But I keep getting this error... "Program '[projectpath]' does not contain a static 'Main' method suitable for an entry point

does that mean I need int Main() somewhere???

Recommended Answers

All 3 Replies

There should be another .cs file containing the Main method. Submit the code of that file.

Hey Thanks... I didn't have the Resources.resx file or the Settings.settings file in the Properties on the Solution Explorer. I added them and then closed and restarted...works now. Hmmm?

Member Avatar for nssltd

There should be a file called program.cs in this file it should contain this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace helloworld
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new helloworld());
        }
    }
}

This file tells which .cs code file to execute first this in your case being form1

Application.Run// This makes the main form or file run.

This may be what you are missing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.