cs 5001 No Main method suitable for entry point

I keep getting the following from code generated by VS2005:

Documents\Visual Studio 2005\Projects\BegCSharpDb\Chapter2_Examples\Chapter2_Examples\obj\Debug\Chapter2_Examples.exe' does not contain a static 'Main' method suitable for an entry point Chapter2_Examples

Please see the code below:

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace Employees

{

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());

}

}

}

How do I resolve this

Incidentally, the braces are in their correct positions in the original code - they just look wrong here.

Ruel



Answer this question

cs 5001 No Main method suitable for entry point

  • pu132

    The two project types were windows, with the first one being an empty application and the second a windows app. I ended up deleting the two projects and creating one project windows project with a windows application.

    When I did that the app worked well and I did not have to have an entry in the startup object field. Do you think that the problem might have been caused from using instructions relating to VS2003 to build a VS2005 project

    Thanks for the assistance you have provided.

    Ruel


  • RR06

    I found that there was no startup object as you suspected I suppose, so I selected Employees.Program, but now Project Properties is looking for the resource file. I tried Resource.resx, but I am not being allowed to use that as a selection.

    Ruel


  • huysmans

    hi

    i solved this problem...you create console application not windows application...if you do it, the problem will solve and not see this error message....

    good luck!




    ----
    to be or not to be....

  • ameyayashu

    Thanks again!

    Ruel


  • MR123

    Hello Again

    I ended up deleting the two projects which consisted of an empty application and windows application and creating one win app which solved the problem.

    Perhaps I should not have followed the instructions from the text which was based on VS2003, since I am using VS2005.

    Thanks for your reply.

    Ruel


  • paso

    I am having the same issue in VS2005. I don't want to uninstall/reinstall VS2005. If I do it might be fix it but it is kinda not solving the root issue.

    What I do is create a new console C# and delete program.cs and add another source file that I know should compile and obviously it has Main function.

    I notice when I go to Project properties, and click on 'Assembly Information' it is all blank.

    Start-up object=(not set)

    Any idea



  • jv_getmore

    Check your project properites. What is selected as the startup object

    --
    SvenC


  • sesnir

    The resources bullet was checked. I checked the icon bullet in the resources panel of the dialog and was able to rerun debugging, but I still get the same error. This project was started with an empty project and then form1 was added subsequently as another project. I following an example from a text before working on my own project.

    Ruel


  • anishettypraveen

    What is looking for a resource file Closing the dialog gives an error Or bulding the project

    --
    SvenC


  • jzfredricks

    What is your output type - same properies page than startup object Is it "Windows Application"

    --
    SvenC


  • ILV

    Thanks for replying-

    I tried pasting the Main method code to Form1.cs but it did not work. I even changed the startup object to employees.form1 but no success.

    Ruel


  • Robert Barnes

    Depends on what those instructions for VS2003 where But it should have behaved like it did. Well - the main point is, that its working now.

    --
    SvenC


  • Tryst

    hi,

    may be this clasas program is not registered for your project build, i'm not sure but try to add other class and copy the program class to it, or copy the Main method to your form1 code

    hope this helps



  • CemSharp

    You cannot change the startup object

    Show us your Main function.

    --
    SvenC


  • cs 5001 No Main method suitable for entry point