Error CS5001 "The program does not contain a 'Main' method"
melvinou22
Posted messages
129
Status
Member
-
Anonymous user -
Anonymous user -
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.
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
-
petite erreur de frappe, je voulais écrire " ... pas de CSC donc je ne sais pas ... "
-
Good evening, is this a dll project?
--
When I was little, the Dead Sea was just unwell.
George Burns -
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 -
What kind of project did you create?
--
When I was a kid, the Dead Sea was just sick.
George Burns -
-
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-
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(); } } } -
-
-
-
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 -
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
-
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