Error CS5001 "The program does not contain a 'Main' method"

Hello,

As the title says, I have an error that says "The program does not contain a static 'Main' method suitable for an entry point" and my biggest problem is that it tells me the error is in the CSC file, it tells me where this file is located on my computer (documents -> Visual Studio 2015 -> project -> pixal) and when I go to that location, I do not find a CSC doc, I do not know where the error is. Thank you in advance for your possible response.

9 answers

  1. petite erreur de frappe, je voulais écrire " ... pas de CSC donc je ne sais pas ... "
    0
    1. Good evening, is this a dll project?

      --
      When I was little, the Dead Sea was just unwell.
      George Burns
      0
      1. I just tested that when you want to launch a dll project, it's not this error message.

        The Main method is (normally) in the Program.cs file.

        It's VS that writes it based on what you entered in the project properties.

        It should look like this:
        using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace Test_Winform { 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()); } } }


        You can modify it especially to handle command line arguments.

        --
        When I was little, the Dead Sea was just sick.
        George Burns
        0
        1. In searching for program.cs, I can't find it anywhere
          and I created a "test" file that is empty so it works
          and there is no program.cs file either so I'm lost.
          0
      2. What kind of project did you create?

        --
        When I was a kid, the Dead Sea was just sick.
        George Burns
        0
        1. Oh, it should have been specified from the beginning, 99% of the questions are about WinForms.....

          The entry point is normally App.xaml.

          The code is as follows
          XAML
          <Application x:Class="Test_WPF_Cs.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> </Application.Resources> </Application> 


          C#
          using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Windows; namespace Test_WPF_Cs { /// <summary> /// Interaction logic for App.xaml /// </summary> public partial class App : Application { } } 


          Be careful with the namespace and the name of the startup page, here MainWindow.xaml

          --
          When I was a kid, the Dead Sea was just sick.
          George Burns
          0
          1. I have a problem, it looks more like this

            XAML
            <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:WpfApplication1"
            mc:Ignorable="d"
            Title="MainWindow" Height="350" Width="525">
            <Grid>

            </Grid>
            </Window>


            and C#

             using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfApplication1 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } } } 
            0
          2. What I just sent you is the C# code and the XAML of the project "temoin", the one that works.
            0
          3. And by comparing, it must not be the error between the one that works and the one that doesn’t work; there is no difference.
            0
        2. At the risk of repeating myself
          The entry point is normally App.xalm.

          When you receive a response, the least you can do is read it carefully.
          The codes you are showing come from MainWindow.xaml and MainWindow.xaml.cs
          --
          When I was little, the Dead Sea was just sick.
          George Burns
          0
          1. I received an email with what you said, but the message does not appear in the conversation. Anyway, as I mentioned earlier, I don't have app.xaml
            0
            1. Oh no, actually I didn't say that. Sorry for getting a bit ahead of myself, and I don't have app.xaml; I only have app.g.i.cs and app.g.cs, and those are documents that won't open.
              0
            2. <translation>Yeah, actually it's good, he opened it, his VS was bugging, but in the end app.xaml I don't have app.g.i.cs and the other ones are not at all what you showed.</translation>
              0
          2. Hello,
            It turns out that I have a similar problem, except that the App.cs file is indeed present in my project! I had removed it and then re-included it in the solution, and since then I have been unable to fix this error...

            If anyone has an opinion on the matter, please feel free to share it, it would be welcome!

            Best regards
            0
            1. Good evening

              I had removed it and then re-included it in the solution

              You shouldn't have...

              I suggest you create a new project and import all your files into it, except for App.xml and App.cs, which should already be there.
              0