I'm trying to screw to the current application, which is located on Form1 running Form2 as a splash screen. But when I try to compile the whole thing, I get an error CS0017 (several entry points for the program are defined).

I understand that I have an entry point on Form1 in the form of InitializeComponent (); But I do not quite understand what to do.

Here is the code:

static void Main() { { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form2 first = new Form2(); DateTime end = DateTime.Now + TimeSpan.FromSeconds(5); first.Show(); while(end>DateTime.Now) { Application.DoEvents(); } first.Close(); first.Dispose(); Application.Run(new Form1()); } } public Form1() { InitializeComponent(); start_game(); } 
  • 3
    How many Main () functions do you have? - tym32167
  • Remove your main. - Qwertiy
  • Removed, but Form2 does not start from this. What am I doing wrong? - Vladimir Void
  • I understand that I have an entry point on Form1 in the form of InitializeComponent (); - entry point is just a function of Main - Grundy

1 answer 1

You are not changing the code there. You start Form1 in Main () , which is located in the Program.cs file, where you can change the code from Form1 to Form2 (the last line of the method).

If Form2 is used as a screensaver, then in it you need to load everything you need and run Form1. If it is just for beauty (judging by your code), then you can simply use a timer and set a delay to it, because you use the loop that you wrote badly, because it will be very processor-intensive. In the timer write something like:

 private void timer1_Tick(object sender, EventArgs e) { var mainForm = new Form2(); Hide(); ShowDialog(); Close(); }